aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/faction_xp.gnut
blob: 5aee110446d9a5167030a260823edb511227e461 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
global function AddFactionXP

void function AddFactionXP( entity player, int amount )
{
	string faction = GetFactionChoice( player )
	int oldLevel = FactionGetLevel( player, faction )
	int FactionXPMatch = player.GetPersistentVarAsInt( "xp_match[" + XP_TYPE.FACTION_LEVELED + "]" )
	
	// increment xp
	player.SetPersistentVar( "factionXP[" + faction + "]", min( FactionGetXP( player, faction ) + amount, FactionGetMaxXP( faction ) ) )
	
	// note: no notif for faction level up
	if ( FactionGetLevel( player, faction ) != oldLevel )
	{
		AddPlayerScore( player, "FactionLevelUp" )
		IncrementPlayerChallengeFactionLeveledUp( player )
		player.SetPersistentVar( "xp_match[" + XP_TYPE.FACTION_LEVELED + "]", FactionXPMatch + 1 )
		
		if( ProgressionEnabledForPlayer( player ) )
			AwardRandomItemsForFactionLevels( player, faction, oldLevel, FactionGetLevel( player, faction ) )
	}
}