aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_gg.gnut
blob: d077e557fdb8e97c1b8cf6082201b1f7910fabab (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
global function ClGamemodeGG_Init

struct {
	int lastScore = -1
} file

void function ClGamemodeGG_Init()
{
	// add ffa gamestate asset
	ClGameState_RegisterGameStateAsset( $"ui/gamestate_info_ffa.rpak" )

	// add music for mode, this is copied directly from the ffa/fra music registered in cl_music.gnut
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_INTRO, "music_mp_freeagents_intro", TEAM_IMC )
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_INTRO, "music_mp_freeagents_intro", TEAM_MILITIA )

	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_WIN, "music_mp_freeagents_outro_win", TEAM_IMC )
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_WIN, "music_mp_freeagents_outro_win", TEAM_MILITIA )

	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_DRAW, "music_mp_freeagents_outro_lose", TEAM_IMC )
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_DRAW, "music_mp_freeagents_outro_lose", TEAM_MILITIA )

	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_LOSS, "music_mp_freeagents_outro_lose", TEAM_IMC )
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_LOSS, "music_mp_freeagents_outro_lose", TEAM_MILITIA )

	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_THREE_MINUTE, "music_mp_freeagents_almostdone", TEAM_IMC )
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_THREE_MINUTE, "music_mp_freeagents_almostdone", TEAM_MILITIA )

	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_LAST_MINUTE, "music_mp_freeagents_lastminute", TEAM_IMC )
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_LAST_MINUTE, "music_mp_freeagents_lastminute", TEAM_MILITIA )

	Cl_GGEarnMeter_Init(ClGamemodeGG_GetWeaponIcon, ClGamemodeGG_ShouldChangeWeaponIcon)
}

asset function ClGamemodeGG_GetWeaponIcon()
{
	int weaponIndex = GameRules_GetTeamScore( GetLocalViewPlayer().GetTeam() ) + 1

	array<GunGameWeapon> weapons = GetGunGameWeapons()

	if ( weaponIndex >= weapons.len() )
		return RandomFloat( 1 ) > 0.1 ? $"rui/menu/boosts/boost_icon_random" : $"rui/faction/faction_logo_mrvn"

	GunGameWeapon nextWeapon = weapons[ weaponIndex ]
	return GetWeaponInfoFileKeyFieldAsset_WithMods_Global( nextWeapon.weapon, nextWeapon.mods, "hud_icon" )
}

// Because of our easter egg we have to include the optional test function so that we don't get a flickering icon.
bool function ClGamemodeGG_ShouldChangeWeaponIcon()
{
	int currentScore = GameRules_GetTeamScore( GetLocalViewPlayer().GetTeam() )

	if ( file.lastScore != currentScore )
	{
		file.lastScore = currentScore
		return true
	}

	return false
}