diff --git a/KFGame/Classes/KFAutoPurchaseHelper.uc b/KFGame/Classes/KFAutoPurchaseHelper.uc index 64892bc..e13cf98 100644 --- a/KFGame/Classes/KFAutoPurchaseHelper.uc +++ b/KFGame/Classes/KFAutoPurchaseHelper.uc @@ -747,7 +747,7 @@ function float FillAmmo( out SItemInformation ItemInfo, optional bool bIsGrenade function int GetFillAmmoCost( out SItemInformation ItemInfo ) { local int AmmoCount, MaxAmmoCount; - local float MissingAmmo, PricePerMag, MagSize, PricePerRound; + local float MissingAmmo, PricePerMag, MagSize, PricePerRound, TotalFill, Fractional; local float AmmoCostScale; local KFGameReplicationInfo KFGRI; @@ -784,8 +784,20 @@ function int GetFillAmmoCost( out SItemInformation ItemInfo ) MissingAmmo = MaxAmmoCount - AmmoCount; PricePerRound = PricePerMag / MagSize; + TotalFill = MissingAmmo * PricePerRound; + // Use FCeil so you can never buy ammo for 0 Do$h on an int conversion - return FCeil(MissingAmmo * PricePerRound); + + // Unreal does a strange thing with a float number that doesn't have decimals, if you ceiling on it it will add 1.0 to it.. + + Fractional = TotalFill - FFloor(TotalFill); + + if (FFloor(TotalFill) != 0 && Fractional < 0.0001f) + { + return FFloor(TotalFill); + } + + return FCeil(TotalFill); } // auto fill diff --git a/KFGame/Classes/KFGFxHUD_PlayerStatus.uc b/KFGame/Classes/KFGFxHUD_PlayerStatus.uc index d8a30ec..bd1f2d1 100644 --- a/KFGame/Classes/KFGFxHUD_PlayerStatus.uc +++ b/KFGame/Classes/KFGFxHUD_PlayerStatus.uc @@ -108,12 +108,20 @@ function UpdateHealer(optional bool bForce) // Update the Healer charge amount if( LastHealerAmmoPct != CurrentHealerAmmoPct || bForce) { - SetInt("playerHealerCharge" , int(CurrentHealerAmmoPct * 100.f)); LastHealerAmmoPct = CurrentHealerAmmoPct; } } +function ResetSyringe(float Ammo, float MaxAmmo) +{ + local float CurrentHealerAmmoPct; + + CurrentHealerAmmoPct = Ammo; + SetInt("playerHealerCharge" , int(CurrentHealerAmmoPct * 100.f)); + LastHealerAmmoPct = MaxAmmo; +} + function UpdatePerk() { local byte CurrentPerkLevel; diff --git a/KFGame/Classes/KFGFxMoviePlayer_HUD.uc b/KFGame/Classes/KFGFxMoviePlayer_HUD.uc index e92b39f..1665e1d 100644 --- a/KFGame/Classes/KFGFxMoviePlayer_HUD.uc +++ b/KFGame/Classes/KFGFxMoviePlayer_HUD.uc @@ -1190,6 +1190,14 @@ function UpdateVIP(ReplicatedVIPGameInfo VIPInfo, bool bIsVIP) } } +function ResetSyringe(float Ammo, float MaxAmmo) +{ + if (PlayerStatusContainer != none) + { + PlayerStatusContainer.ResetSyringe(Ammo, MaxAmmo); + } +} + //============================================================== // Input //============================================================== diff --git a/KFGame/Classes/KFPlayerController_WeeklySurvival.uc b/KFGame/Classes/KFPlayerController_WeeklySurvival.uc index 3ee5510..5c30ed2 100644 --- a/KFGame/Classes/KFPlayerController_WeeklySurvival.uc +++ b/KFGame/Classes/KFPlayerController_WeeklySurvival.uc @@ -208,6 +208,35 @@ simulated function UpdateVIPWidget(ReplicatedVIPGameInfo VIPInfo) } } +reliable client function ResetSyringe() +{ + local KFInventoryManager InventoryManager; + local KFWeapon CurrentWeapon; + + InventoryManager = KFInventoryManager(Pawn.InvManager); + + if (InventoryManager.HealerWeapon == none) + { + foreach InventoryManager.InventoryActors ( class'KFWeapon', CurrentWeapon ) + { + if (KFWeap_HealerBase(CurrentWeapon) != none) + { + InventoryManager.HealerWeapon = KFWeap_HealerBase(CurrentWeapon); + } + } + } + + if (InventoryManager.HealerWeapon != none) + { + InventoryManager.HealerWeapon.AmmoCount[0] = InventoryManager.HealerWeapon.MagazineCapacity[0]; + + if (MyGFxHUD != none) + { + MyGFxHUD.ResetSyringe(InventoryManager.HealerWeapon.AmmoCount[0], InventoryManager.HealerWeapon.MagazineCapacity[0]); + } + } +} + function bool CanUseHealObject() { local KFGameReplicationInfo KFGRI; diff --git a/KFGame/Classes/KFProfileSettings.uc b/KFGame/Classes/KFProfileSettings.uc index 8c530b3..500e513 100644 --- a/KFGame/Classes/KFProfileSettings.uc +++ b/KFGame/Classes/KFProfileSettings.uc @@ -24,10 +24,20 @@ var transient bool Dirty; event FavoriteWeapon(name WeaponName) { - if(FavoriteWeapons.Find(string(WeaponName)) == INDEX_NONE) + if (FavoriteWeapons.Find(string(WeaponName)) == INDEX_NONE) { // Only add if unique FavoriteWeapons.AddItem(string(WeaponName)); + + while (FavoriteWeapons.Length > 12) + { + // There's a crash on the save system because the string this generates is huge + // It usually happens when you start having more than 12 weapons as Favorite + // We are going to cap it then, we remove from the beginning + + FavoriteWeapons.Remove(0, 1); + } + Dirty = true; } } diff --git a/KFGame/Classes/KFWeap_HealerBase.uc b/KFGame/Classes/KFWeap_HealerBase.uc index 0297720..ee84f1c 100644 --- a/KFGame/Classes/KFWeap_HealerBase.uc +++ b/KFGame/Classes/KFWeap_HealerBase.uc @@ -117,6 +117,8 @@ function GivenTo(Pawn NewOwner, optional bool bDoNotActivate) KFInvManger = KFInventoryManager(InvManager); if( InvManager != none && KFInvManger != none ) { + `Log("GivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenTo"); + KFInvManger.HealerWeapon = self; } } diff --git a/KFGame/Classes/KFWeapon.uc b/KFGame/Classes/KFWeapon.uc index 7f316b5..a702e51 100644 --- a/KFGame/Classes/KFWeapon.uc +++ b/KFGame/Classes/KFWeapon.uc @@ -6087,7 +6087,10 @@ simulated state WeaponEquipping CurrentPerk = GetPerk(); if( CurrentPerk != none ) { - CurrentPerk.ModifyWeaponSwitchTime( ScaledRate ); + if( CurrentPerk.IsWeaponOnPerk( self,, CurrentPerk.class ) ) + { + CurrentPerk.ModifyWeaponSwitchTime( ScaledRate ); + } } return 1.f / ScaledRate; @@ -6113,7 +6116,10 @@ simulated function TimeWeaponEquipping() InstigatorPerk = GetPerk(); if( InstigatorPerk != none ) { - InstigatorPerk.ModifyWeaponSwitchTime( ModifiedEquipTime ); + if( InstigatorPerk.IsWeaponOnPerk( self,, InstigatorPerk.class ) ) + { + InstigatorPerk.ModifyWeaponSwitchTime( ModifiedEquipTime ); + } } // Play the animation @@ -6190,7 +6196,10 @@ simulated state WeaponPuttingDown CurrentPerk = GetPerk(); if( CurrentPerk != none ) { - CurrentPerk.ModifyWeaponSwitchTime( ScaledRate ); + if( CurrentPerk.IsWeaponOnPerk( self,, CurrentPerk.class ) ) + { + CurrentPerk.ModifyWeaponSwitchTime( ScaledRate ); + } } return 1.f / ScaledRate; @@ -6366,7 +6375,10 @@ simulated function TimeWeaponPutDown() InstigatorPerk = GetPerk(); if( InstigatorPerk != none ) { - InstigatorPerk.ModifyWeaponSwitchTime( ModifiedPutDownTime ); + if( InstigatorPerk.IsWeaponOnPerk( self,, InstigatorPerk.class ) ) + { + InstigatorPerk.ModifyWeaponSwitchTime( ModifiedPutDownTime ); + } } SetTimer( ModifiedPutDownTime > 0 ? ModifiedPutDownTime : 0.01, false, nameof(WeaponIsDown) ); diff --git a/KFGameContent/Classes/KFGameInfo_WeeklySurvival.uc b/KFGameContent/Classes/KFGameInfo_WeeklySurvival.uc index a9f86ee..8dc8719 100644 --- a/KFGameContent/Classes/KFGameInfo_WeeklySurvival.uc +++ b/KFGameContent/Classes/KFGameInfo_WeeklySurvival.uc @@ -1646,6 +1646,7 @@ function PerkRoulette_InventoryCustomDelegate() local KFPerk Perk; local int i; local byte NewPerk; + local KFInventoryManager InventoryManager; for (i = PerkRoulette_PlayersDelegateInventory.Length - 1 ; i >= 0 ; --i) { @@ -1680,6 +1681,16 @@ function PerkRoulette_InventoryCustomDelegate() AddDefaultInventory(KFPC_WS.Pawn); PerkRoulette_PlayersDelegateInventory.Remove(i, 1); + + // Force fill syringe + InventoryManager = KFInventoryManager(KFPC_WS.Pawn.InvManager); + + if (InventoryManager.HealerWeapon != none) + { + InventoryManager.HealerWeapon.AmmoCount[0] = InventoryManager.HealerWeapon.MagazineCapacity[0]; + } + + KFPC_WS.ResetSyringe(); } } diff --git a/KFGameContent/Classes/KFProj_HRG_Locust.uc b/KFGameContent/Classes/KFProj_HRG_Locust.uc index 90cad39..85f0a45 100644 --- a/KFGameContent/Classes/KFProj_HRG_Locust.uc +++ b/KFGameContent/Classes/KFProj_HRG_Locust.uc @@ -77,6 +77,8 @@ simulated protected function PrepareExplosionTemplate() super(KFProjectile).PrepareExplosionTemplate(); + ExplosionTemplate.bIgnoreInstigator = true; + OwnerWeapon = Weapon(Owner); if (OwnerWeapon != none) {