KF2-Server-Extension/ServerExt/Classes/ExtHUD_WeaponSelectWidget.uc

92 lines
2.7 KiB
Ucode
Raw Normal View History

class ExtHUD_WeaponSelectWidget extends KFGFxHUD_WeaponSelectWidget;
var transient array< class<KFWeaponDefinition> > WeaponGroup;
2020-11-28 20:04:55 +00:00
simulated function UpdateWeaponGroupOnHUD(byte GroupIndex)
{
2020-11-28 19:53:57 +00:00
local Inventory Inv;
local KFWeapon KFW;
local byte i;
local int Index;
local array<KFWeapon> WeaponsList;
local KFGFxObject_TraderItems TraderItems;
local Pawn P;
local array< class<KFWeaponDefinition> > WPGroup;
2020-11-28 19:53:57 +00:00
P = GetPC().Pawn;
2020-11-28 20:04:55 +00:00
if (P == none || P.InvManager == none)
2020-11-28 19:53:57 +00:00
return;
2020-11-28 20:04:55 +00:00
for (Inv = P.InvManager.InventoryChain; Inv != none; Inv = Inv.Inventory)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
KFW = KFWeapon(Inv);
if (KFW != none && KFW.InventoryGroup == GroupIndex)
2020-11-28 19:53:57 +00:00
WeaponsList.AddItem(KFW);
}
2020-11-28 19:53:57 +00:00
WPGroup.Length = WeaponsList.Length;
2020-11-28 20:04:55 +00:00
TraderItems = KFGameReplicationInfo(P.WorldInfo.GRI).TraderItems;
for (i = 0; i < WeaponsList.Length; i++)
2020-11-28 19:53:57 +00:00
{
Index = TraderItems.SaleItems.Find('ClassName', WeaponsList[i].Class.Name);
2020-11-28 20:12:58 +00:00
if (Index != -1)
2020-11-28 19:53:57 +00:00
WPGroup[i] = TraderItems.SaleItems[Index].WeaponDef;
}
2020-11-28 19:53:57 +00:00
WeaponGroup = WPGroup;
SetWeaponGroupList(WeaponsList, GroupIndex);
}
simulated function SetWeaponGroupList(out array<KFWeapon> WeaponList, byte GroupIndex)
{
2020-11-28 19:53:57 +00:00
local byte i;
local GFxObject DataProvider;
local GFxObject TempObj;
local bool bUsesAmmo;
2020-11-28 19:53:57 +00:00
DataProvider = CreateArray();
2020-11-28 20:04:55 +00:00
if (DataProvider == None)
2020-11-28 19:53:57 +00:00
return; // gfx has been shut down
2020-11-28 19:53:57 +00:00
for (i = 0; i < WeaponList.length; i++)
{
2020-11-28 20:04:55 +00:00
TempObj = CreateObject("Object");
2020-11-28 20:12:58 +00:00
if (WeaponGroup[i] != None)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
TempObj.SetString("weaponName", WeaponGroup[i].static.GetItemLocalization("ItemName"));
TempObj.SetString("texturePath", "img://"$WeaponGroup[i].static.GetImagePath());
2020-11-28 19:53:57 +00:00
}
2023-05-14 02:49:12 +00:00
else
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
TempObj.SetString("weaponName", WeaponList[i].ItemName);
TempObj.SetString("texturePath", "img://"$PathName(WeaponList[i].WeaponSelectTexture));
2020-11-28 19:53:57 +00:00
}
2020-11-28 19:53:57 +00:00
TempObj.SetInt("weaponTier", WeaponList[i].CurrentWeaponUpgradeIndex);
2020-11-28 20:04:55 +00:00
TempObj.SetInt("ammoCount", WeaponList[i].AmmoCount[0]);
TempObj.SetInt("spareAmmoCount", WeaponList[i].SpareAmmoCount[0]);
2020-11-28 19:53:57 +00:00
//secondary ammo shenanigans
TempObj.SetBool("bUsesSecondaryAmmo", WeaponList[i].UsesSecondaryAmmo()&&WeaponList[i].bCanRefillSecondaryAmmo);
TempObj.SetBool("bEnabled", WeaponList[i].HasAnyAmmo());
2020-11-28 20:12:58 +00:00
if (WeaponList[i].UsesSecondaryAmmo() && WeaponList[i].bCanRefillSecondaryAmmo)
2020-11-28 19:53:57 +00:00
{
TempObj.SetBool("bCanRefillSecondaryAmmo", WeaponList[i].SpareAmmoCapacity[1] > 0);
2020-11-28 20:04:55 +00:00
TempObj.SetInt("secondaryAmmoCount", WeaponList[i].AmmoCount[1]);
TempObj.SetInt("secondarySpareAmmoCount", WeaponList[i].SpareAmmoCount[1]);
2020-11-28 19:53:57 +00:00
}
2020-11-28 20:04:55 +00:00
TempObj.SetBool("throwable", WeaponList[i].CanThrow());
2020-11-28 19:53:57 +00:00
bUsesAmmo = (WeaponList[i].static.UsesAmmo());
2020-11-28 20:04:55 +00:00
TempObj.SetBool("bUsesAmmo", bUsesAmmo);
DataProvider.SetElementObject(i, TempObj);
2020-11-28 19:53:57 +00:00
}
2020-11-28 19:53:57 +00:00
SetWeaponList(DataProvider, GroupIndex);
}
2022-09-02 13:08:18 +00:00
defaultproperties
{
2023-05-14 02:49:12 +00:00
}