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

74 lines
2.0 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
class ExtTraderContainer_Store extends KFGFxTraderContainer_Store;
function RefreshWeaponListByPerk(byte FilterIndex, const out array<STraderItem> ItemList)
{
local int i, SlotIndex;
local GFxObject ItemDataArray; // This array of information is sent to ActionScript to update the Item data
local array<STraderItem> OnPerkWeapons, SecondaryWeapons, OffPerkWeapons;
local class<KFPerk> TargetPerkClass;
local ExtPlayerController EKFPC;
EKFPC = ExtPlayerController(KFPC);
2020-11-28 20:04:55 +00:00
if (EKFPC!=none && EKFPC.ActivePerkManager!=None)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:04:55 +00:00
if(FilterIndex<EKFPC.ActivePerkManager.UserPerks.Length)
2017-10-20 02:00:49 +00:00
TargetPerkClass = EKFPC.ActivePerkManager.UserPerks[FilterIndex].BasePerk;
SlotIndex = 0;
2020-11-28 19:53:57 +00:00
ItemDataArray = CreateArray();
2017-10-20 02:00:49 +00:00
for (i = 0; i < ItemList.Length; i++)
{
2020-11-28 20:04:55 +00:00
if (IsItemFiltered(ItemList[i]))
2017-10-20 02:00:49 +00:00
{
continue; // Skip this item if it's in our inventory
}
2020-11-28 20:04:55 +00:00
else if (ItemList[i].AssociatedPerkClasses.length > 0 && ItemList[i].AssociatedPerkClasses[0] != none && TargetPerkClass != class'KFPerk_Survivalist'
&& (TargetPerkClass==None || ItemList[i].AssociatedPerkClasses.Find(TargetPerkClass) == INDEX_NONE))
2017-10-20 02:00:49 +00:00
{
continue; // filtered by perk
}
else
{
if(ItemList[i].AssociatedPerkClasses.length > 0)
{
switch (ItemList[i].AssociatedPerkClasses.Find(TargetPerkClass))
{
case 0: //primary perk
OnPerkWeapons.AddItem(ItemList[i]);
break;
case 1: //secondary perk
SecondaryWeapons.AddItem(ItemList[i]);
break;
default: //off perk
OffPerkWeapons.AddItem(ItemList[i]);
break;
}
}
}
}
for (i = 0; i < OnPerkWeapons.length; i++)
{
SetItemInfo(ItemDataArray, OnPerkWeapons[i], SlotIndex);
SlotIndex++;
}
for (i = 0; i < SecondaryWeapons.length; i++)
{
SetItemInfo(ItemDataArray, SecondaryWeapons[i], SlotIndex);
SlotIndex++;
}
for (i = 0; i < OffPerkWeapons.length; i++)
{
SetItemInfo(ItemDataArray, OffPerkWeapons[i], SlotIndex);
SlotIndex++;
}
SetObject("shopData", ItemDataArray);
}
}