aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/weapon_xp.gnut
blob: 0b0084b3cceadca022c99dce19d36c027410d89f (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
untyped
global function AddWeaponXP

void function AddWeaponXP( entity player, int amount )
{
	entity activeWeapon = player.GetActiveWeapon()
	string weaponClassname = activeWeapon.GetWeaponClassName()
	int oldLevel = WeaponGetLevel( player, weaponClassname )
	int WeaponXPMatch = player.GetPersistentVarAsInt( "xp_match[" + XP_TYPE.WEAPON_LEVELED + "]" )
	
	// increment xp
	player.SetPersistentVar( GetItemPersistenceStruct( weaponClassname ) + ".weaponXP", min( WeaponGetXP( player, weaponClassname ) + amount, WeaponGetMaxXP( weaponClassname ) ) )
	Remote_CallFunction_NonReplay( player, "ServerCallback_WeaponXPAdded", shWeaponXP.weaponClassNames.find( weaponClassname ), WeaponGetXP( player, weaponClassname ), amount )
	
	// level up notif
	if ( WeaponGetLevel( player, weaponClassname ) != oldLevel )
	{
		Remote_CallFunction_NonReplay( player, "ServerCallback_WeaponLeveledUp", shWeaponXP.weaponClassNames.find( weaponClassname ), WeaponGetGen( player, weaponClassname ), WeaponGetLevel( player, weaponClassname ) )
		AddPlayerScore( player, "WeaponLevelUp" )
		IncrementPlayerChallengeWeaponLeveledUp( player )
		player.SetPersistentVar( "xp_match[" + XP_TYPE.WEAPON_LEVELED + "]", WeaponXPMatch + 1 )
		
		if( ProgressionEnabledForPlayer( player ) )
			AwardRandomItemsForWeaponLevels( player, weaponClassname, oldLevel, WeaponGetLevel( player, weaponClassname ) )
	}

	// proscreen 
	if ( player == activeWeapon.GetProScreenOwner() )
	{
		player.SetPersistentVar( GetItemPersistenceStruct( weaponClassname ) + ".proScreenKills", WeaponGetProScreenKills( player, weaponClassname ) + amount )
		
		// not currently used rn, but adding a script var so scripts can handle proscreen values manually if wanted
		if ( !( "manualProscreenControl" in activeWeapon.s && activeWeapon.s.manualProscreenControl ) )
			activeWeapon.SetProScreenIntValForIndex( 0, WeaponGetProScreenKills( player, weaponClassname ) )
	}
}