Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reliable server simulated final function UpdateWeaponSpareAmmo( CD_Weap_TacticalBackpack TacticalBackpack, optional KFWeapon AddedWeapon, optional int ButtPackIndex = 255 )
- {
- local int i, Index, RemainingSpareAmmoCount;
- local bool bItemIsInInventory;
- local array<int> DefaultSpareAmmoCount, DefaultSpareAmmoCapacity, PouchSpareAmmoCapacity;
- local KFInventoryManager KFIM;
- local Inventory Inv;
- local KFWeapon KFW;
- KFIM = KFInventoryManager( InvManager );
- if ( KFIM != None && TacticalBackpack != None )
- {
- TacticalBackpack.UpdateButtPackAmmoInfo();
- if ( ButtPackIndex != 255 )
- {
- for ( i = 0; i < TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo.Length; i++ )
- {
- if ( KFIM.GetWeaponFromClass( KFW, TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].ClassName ) )
- {
- if ( KFW != None && KFW.UsesAmmo() && !KFW.IsA( 'CD_Weap_TacticalBackpack' ) && !KFW.IsA( 'KFWeap_AmmoBag' ) && !KFW.IsA( 'KFWeap_ArmorSupply' ) && !KFW.IsA( 'KFWeap_MediKit' ))
- {
- UpdateWeaponPrimarySpareAmmo( KFW );
- if ( KFW.SpareAmmoCount[0] > TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].DefaultSpareAmmoCount[0] )
- {
- RemainingSpareAmmoCount = KFW.SpareAmmoCount[0] - TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].DefaultSpareAmmoCount[0];
- TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCount[0] += Min( RemainingSpareAmmoCount, TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCapacity[0] );
- TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCount[0] = Min( TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCount[0],
- TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCapacity[0] );
- KFW.AddAmmo( -Min( RemainingSpareAmmoCount, TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCapacity[0] ) );
- UpdateWeaponPrimarySpareAmmo( KFW );
- }
- if ( KFW.UsesSecondaryAmmo() )
- {
- UpdateWeaponAltSpareAmmo( KFW );
- if ( KFW.SpareAmmoCount[1] > TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].DefaultSpareAmmoCount[1] )
- {
- RemainingSpareAmmoCount = KFW.SpareAmmoCount[1] - TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].DefaultSpareAmmoCount[1];
- TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCount[1] += Min( RemainingSpareAmmoCount, TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCapacity[1] );
- TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCount[1] = Min( TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCount[1],
- TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCapacity[1] );
- KFW.AddSecondaryAmmo( -Min( RemainingSpareAmmoCount, TacticalBackpack.ButtPackAmmo[ButtPackIndex].ButtPackAmmoInfo[i].SpareAmmoCapacity[1] ) );
- UpdateWeaponAltSpareAmmo( KFW );
- }
- }
- }
- }
- }
- }
- else
- {
- for ( i = 0; i < TacticalBackpack.ButtPackAmount; i++ )
- {
- for ( Inv = InvManager.InventoryChain; Inv != None; Inv = Inv.Inventory )
- {
- KFW = KFWeapon( Inv );
- if ( KFW != None && KFW.UsesAmmo() && !KFW.IsA( 'CD_Weap_TacticalBackpack' ) && !KFW.IsA( 'KFWeap_AmmoBag' ) && !KFW.IsA( 'KFWeap_ArmorSupply' ) && !KFW.IsA( 'KFWeap_MediKit' ) )
- {
- Index = TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo.Find( 'ClassName', KFW.Class.Name );
- if ( Index < 0 )
- {
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo.Length = TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo.Length + 1;
- Index = TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo.Length - 1;
- }
- bItemIsInInventory = false;
- if ( !bItemIsInInventory )
- bItemIsInInventory = Index >= 0;
- if ( AddedWeapon != None )
- bItemIsInInventory = ( Index >= 0 && AddedWeapon.Class.Name == KFW.Class.Name );
- if ( bItemIsInInventory )
- {
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].ClassName = KFW.Class.Name;
- DefaultSpareAmmoCount.Length = 2;
- DefaultSpareAmmoCount[0] = KFW.default.MagazineCapacity[0] + ( KFW.default.InitialSpareMags[0] * KFW.default.MagazineCapacity[0] );
- DefaultSpareAmmoCount[1] = KFW.default.MagazineCapacity[1] + ( KFW.default.InitialSpareMags[1] * KFW.default.MagazineCapacity[1] );
- if ( KFW.GetPerk() != None )
- {
- KFW.GetPerk().ModifySpareAmmoAmount( KFW, DefaultSpareAmmoCount[0] );
- KFW.GetPerk().ModifySpareAmmoAmount( KFW, DefaultSpareAmmoCount[1],, true );
- }
- DefaultSpareAmmoCapacity[0] = KFW.default.SpareAmmoCapacity[0];
- DefaultSpareAmmoCapacity[1] = KFW.default.SpareAmmoCapacity[1];
- KFW.ModifySpareAmmoCapacity( DefaultSpareAmmoCapacity[0], class'KFWeapon'.const.DEFAULT_FIREMODE );
- if ( KFW.UsesSecondaryAmmo() )
- KFW.ModifySpareAmmoCapacity( DefaultSpareAmmoCapacity[1], class'KFWeapon'.const.ALTFIRE_FIREMODE );
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[0] = Max( ( DefaultSpareAmmoCapacity[0] - DefaultSpareAmmoCount[0] ) / 5, 0 );
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[1] = Max( ( DefaultSpareAmmoCapacity[1] - DefaultSpareAmmoCount[1] ) / 5, 0 );
- UpdateWeaponPrimarySpareAmmo( KFW );
- if ( KFW.SpareAmmoCount[0] > DefaultSpareAmmoCount[0] )
- {
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCount[0] += Min( KFW.SpareAmmoCount[0] - DefaultSpareAmmoCount[0],
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[0] );
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCount[0] = Min( TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCount[0],
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[0] );
- KFW.AddAmmo( -Min( KFW.SpareAmmoCount[0] - DefaultSpareAmmoCount[0], TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[0] ) );
- UpdateWeaponPrimarySpareAmmo( KFW );
- }
- if ( KFW.UsesSecondaryAmmo() )
- {
- UpdateWeaponAltSpareAmmo( KFW );
- if ( KFW.SpareAmmoCount[1] > DefaultSpareAmmoCount[1] )
- {
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCount[1] += Min( KFW.SpareAmmoCount[1] - DefaultSpareAmmoCount[1],
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[1] );
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCount[1] = Min( TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCount[1],
- TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[1] );
- KFW.AddSecondaryAmmo( -Min( KFW.SpareAmmoCount[1] - DefaultSpareAmmoCount[1], TacticalBackpack.ButtPackAmmo[i].ButtPackAmmoInfo[Index].SpareAmmoCapacity[1] ) );
- UpdateWeaponAltSpareAmmo( KFW );
- }
- }
- }
- }
- }
- }
- if ( NumSpareAmmoPouch > 0 )
- {
- for ( Inv = InvManager.InventoryChain; Inv != None; Inv = Inv.Inventory )
- {
- KFW = KFWeapon( Inv );
- if ( KFW != None && KFW.UsesAmmo() && !KFW.IsA( 'CD_Weap_TacticalBackpack' ) && !KFW.IsA( 'KFWeap_AmmoBag' ) && !KFW.IsA( 'KFWeap_ArmorSupply' ) && !KFW.IsA( 'KFWeap_MediKit' ) )
- {
- Index = TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo.Find( 'ClassName', KFW.Class.Name );
- if ( Index < 0 )
- {
- TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo.Length = TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo.Length + 1;
- Index = TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo.Length - 1;
- }
- bItemIsInInventory = false;
- if ( !bItemIsInInventory )
- bItemIsInInventory = Index >= 0;
- if ( AddedWeapon != None )
- bItemIsInInventory = ( Index >= 0 && AddedWeapon.Class.Name == KFW.Class.Name );
- if ( bItemIsInInventory )
- {
- TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo[Index].ClassName = KFW.Class.Name;
- DefaultSpareAmmoCount.Length = 2;
- DefaultSpareAmmoCount[0] = KFW.default.MagazineCapacity[0] + ( KFW.default.InitialSpareMags[0] * KFW.default.MagazineCapacity[0] );
- DefaultSpareAmmoCount[1] = KFW.default.MagazineCapacity[1] + ( KFW.default.InitialSpareMags[1] * KFW.default.MagazineCapacity[1] );
- if ( KFW.GetPerk() != None )
- {
- KFW.GetPerk().ModifySpareAmmoAmount( KFW, DefaultSpareAmmoCount[0] );
- KFW.GetPerk().ModifySpareAmmoAmount( KFW, DefaultSpareAmmoCount[1],, true );
- }
- PouchSpareAmmoCapacity.Length = 2;
- PouchSpareAmmoCapacity[0] = 0;
- PouchSpareAmmoCapacity[1] = 0;
- for ( i = 0; i < NumSpareAmmoPouch; i++ )
- {
- PouchSpareAmmoCapacity[0] += Max( KFW.AmmoPickupScale[0] * KFW.default.MagazineCapacity[0], 1 );
- PouchSpareAmmoCapacity[1] += Max( KFW.AmmoPickupScale[1] * KFW.default.MagazineCapacity[1], 1 );
- }
- UpdateWeaponPrimarySpareAmmo( KFW );
- if ( KFW.SpareAmmoCount[0] > DefaultSpareAmmoCount[0] )
- {
- TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo[Index].PouchSpareAmmoCount[0] += Min( KFW.SpareAmmoCount[0] - DefaultSpareAmmoCount[0], PouchSpareAmmoCapacity[0] );
- TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo[Index].PouchSpareAmmoCount[0] = Min( TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo[Index].PouchSpareAmmoCount[0], PouchSpareAmmoCapacity[0] );
- KFW.AddAmmo( -Min( KFW.SpareAmmoCount[0] - DefaultSpareAmmoCount[0], PouchSpareAmmoCapacity[0] ) );
- UpdateWeaponPrimarySpareAmmo( KFW );
- }
- UpdateWeaponAltSpareAmmo( KFW );
- if ( KFW.UsesSecondaryAmmo() && KFW.SpareAmmoCount[1] > DefaultSpareAmmoCount[1] )
- {
- TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo[Index].PouchSpareAmmoCount[1] += Min( KFW.SpareAmmoCount[1] - DefaultSpareAmmoCount[1], PouchSpareAmmoCapacity[1] );
- TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo[Index].PouchSpareAmmoCount[1] = Min( TacticalBackpack.SpareAmmoPouch.SpareAmmoPouchInfo[Index].PouchSpareAmmoCount[1], PouchSpareAmmoCapacity[1] );
- KFW.AddSecondaryAmmo( -Min( KFW.SpareAmmoCount[1] - DefaultSpareAmmoCount[1], PouchSpareAmmoCapacity[1] ) );
- UpdateWeaponAltSpareAmmo( KFW );
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement