1
0
This commit is contained in:
GenZmeY 2023-03-18 01:57:42 +03:00
parent 2942d046da
commit 688183c1f1
9 changed files with 102 additions and 8 deletions

View File

@ -747,7 +747,7 @@ function float FillAmmo( out SItemInformation ItemInfo, optional bool bIsGrenade
function int GetFillAmmoCost( out SItemInformation ItemInfo ) function int GetFillAmmoCost( out SItemInformation ItemInfo )
{ {
local int AmmoCount, MaxAmmoCount; local int AmmoCount, MaxAmmoCount;
local float MissingAmmo, PricePerMag, MagSize, PricePerRound; local float MissingAmmo, PricePerMag, MagSize, PricePerRound, TotalFill, Fractional;
local float AmmoCostScale; local float AmmoCostScale;
local KFGameReplicationInfo KFGRI; local KFGameReplicationInfo KFGRI;
@ -784,8 +784,20 @@ function int GetFillAmmoCost( out SItemInformation ItemInfo )
MissingAmmo = MaxAmmoCount - AmmoCount; MissingAmmo = MaxAmmoCount - AmmoCount;
PricePerRound = PricePerMag / MagSize; PricePerRound = PricePerMag / MagSize;
TotalFill = MissingAmmo * PricePerRound;
// Use FCeil so you can never buy ammo for 0 Do$h on an int conversion // 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 // auto fill

View File

@ -108,12 +108,20 @@ function UpdateHealer(optional bool bForce)
// Update the Healer charge amount // Update the Healer charge amount
if( LastHealerAmmoPct != CurrentHealerAmmoPct || bForce) if( LastHealerAmmoPct != CurrentHealerAmmoPct || bForce)
{ {
SetInt("playerHealerCharge" , int(CurrentHealerAmmoPct * 100.f)); SetInt("playerHealerCharge" , int(CurrentHealerAmmoPct * 100.f));
LastHealerAmmoPct = CurrentHealerAmmoPct; LastHealerAmmoPct = CurrentHealerAmmoPct;
} }
} }
function ResetSyringe(float Ammo, float MaxAmmo)
{
local float CurrentHealerAmmoPct;
CurrentHealerAmmoPct = Ammo;
SetInt("playerHealerCharge" , int(CurrentHealerAmmoPct * 100.f));
LastHealerAmmoPct = MaxAmmo;
}
function UpdatePerk() function UpdatePerk()
{ {
local byte CurrentPerkLevel; local byte CurrentPerkLevel;

View File

@ -1190,6 +1190,14 @@ function UpdateVIP(ReplicatedVIPGameInfo VIPInfo, bool bIsVIP)
} }
} }
function ResetSyringe(float Ammo, float MaxAmmo)
{
if (PlayerStatusContainer != none)
{
PlayerStatusContainer.ResetSyringe(Ammo, MaxAmmo);
}
}
//============================================================== //==============================================================
// Input // Input
//============================================================== //==============================================================

View File

@ -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() function bool CanUseHealObject()
{ {
local KFGameReplicationInfo KFGRI; local KFGameReplicationInfo KFGRI;

View File

@ -24,10 +24,20 @@ var transient bool Dirty;
event FavoriteWeapon(name WeaponName) event FavoriteWeapon(name WeaponName)
{ {
if(FavoriteWeapons.Find(string(WeaponName)) == INDEX_NONE) if (FavoriteWeapons.Find(string(WeaponName)) == INDEX_NONE)
{ {
// Only add if unique // Only add if unique
FavoriteWeapons.AddItem(string(WeaponName)); 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; Dirty = true;
} }
} }

View File

@ -117,6 +117,8 @@ function GivenTo(Pawn NewOwner, optional bool bDoNotActivate)
KFInvManger = KFInventoryManager(InvManager); KFInvManger = KFInventoryManager(InvManager);
if( InvManager != none && KFInvManger != none ) if( InvManager != none && KFInvManger != none )
{ {
`Log("GivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenToGivenTo");
KFInvManger.HealerWeapon = self; KFInvManger.HealerWeapon = self;
} }
} }

View File

@ -6087,7 +6087,10 @@ simulated state WeaponEquipping
CurrentPerk = GetPerk(); CurrentPerk = GetPerk();
if( CurrentPerk != none ) if( CurrentPerk != none )
{ {
CurrentPerk.ModifyWeaponSwitchTime( ScaledRate ); if( CurrentPerk.IsWeaponOnPerk( self,, CurrentPerk.class ) )
{
CurrentPerk.ModifyWeaponSwitchTime( ScaledRate );
}
} }
return 1.f / ScaledRate; return 1.f / ScaledRate;
@ -6113,7 +6116,10 @@ simulated function TimeWeaponEquipping()
InstigatorPerk = GetPerk(); InstigatorPerk = GetPerk();
if( InstigatorPerk != none ) if( InstigatorPerk != none )
{ {
InstigatorPerk.ModifyWeaponSwitchTime( ModifiedEquipTime ); if( InstigatorPerk.IsWeaponOnPerk( self,, InstigatorPerk.class ) )
{
InstigatorPerk.ModifyWeaponSwitchTime( ModifiedEquipTime );
}
} }
// Play the animation // Play the animation
@ -6190,7 +6196,10 @@ simulated state WeaponPuttingDown
CurrentPerk = GetPerk(); CurrentPerk = GetPerk();
if( CurrentPerk != none ) if( CurrentPerk != none )
{ {
CurrentPerk.ModifyWeaponSwitchTime( ScaledRate ); if( CurrentPerk.IsWeaponOnPerk( self,, CurrentPerk.class ) )
{
CurrentPerk.ModifyWeaponSwitchTime( ScaledRate );
}
} }
return 1.f / ScaledRate; return 1.f / ScaledRate;
@ -6366,7 +6375,10 @@ simulated function TimeWeaponPutDown()
InstigatorPerk = GetPerk(); InstigatorPerk = GetPerk();
if( InstigatorPerk != none ) if( InstigatorPerk != none )
{ {
InstigatorPerk.ModifyWeaponSwitchTime( ModifiedPutDownTime ); if( InstigatorPerk.IsWeaponOnPerk( self,, InstigatorPerk.class ) )
{
InstigatorPerk.ModifyWeaponSwitchTime( ModifiedPutDownTime );
}
} }
SetTimer( ModifiedPutDownTime > 0 ? ModifiedPutDownTime : 0.01, false, nameof(WeaponIsDown) ); SetTimer( ModifiedPutDownTime > 0 ? ModifiedPutDownTime : 0.01, false, nameof(WeaponIsDown) );

View File

@ -1646,6 +1646,7 @@ function PerkRoulette_InventoryCustomDelegate()
local KFPerk Perk; local KFPerk Perk;
local int i; local int i;
local byte NewPerk; local byte NewPerk;
local KFInventoryManager InventoryManager;
for (i = PerkRoulette_PlayersDelegateInventory.Length - 1 ; i >= 0 ; --i) for (i = PerkRoulette_PlayersDelegateInventory.Length - 1 ; i >= 0 ; --i)
{ {
@ -1680,6 +1681,16 @@ function PerkRoulette_InventoryCustomDelegate()
AddDefaultInventory(KFPC_WS.Pawn); AddDefaultInventory(KFPC_WS.Pawn);
PerkRoulette_PlayersDelegateInventory.Remove(i, 1); 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();
} }
} }

View File

@ -77,6 +77,8 @@ simulated protected function PrepareExplosionTemplate()
super(KFProjectile).PrepareExplosionTemplate(); super(KFProjectile).PrepareExplosionTemplate();
ExplosionTemplate.bIgnoreInstigator = true;
OwnerWeapon = Weapon(Owner); OwnerWeapon = Weapon(Owner);
if (OwnerWeapon != none) if (OwnerWeapon != none)
{ {