Compare commits

...

5 Commits

Author SHA1 Message Date
a51b99fe99
update description.txt 2024-04-28 20:53:02 +03:00
60d2b06ee4
add CHN and CHT localizations
translator: cheungfatzong
https://steamcommunity.com/profiles/76561199126205919
2024-04-28 20:10:14 +03:00
a2b16a4306
Update description.txt 2024-03-24 21:53:18 +03:00
c2c6006260
fix InvManager initialization after player death 2024-02-25 17:03:08 +03:00
6d7f0552db
fix single player mode 2024-01-08 12:12:54 +03:00
8 changed files with 118 additions and 28 deletions

View File

@ -230,6 +230,7 @@ private function PostInit()
{
if (RepInfo.PendingSync)
{
RepInfo.PrepareSync(Self, LogLevel, KFGI.KFGFxManagerClass, DLCSkinUpdateRequired.Value, bApplyPatch);
RepInfo.Replicate(WeapDefs);
}
}
@ -348,12 +349,11 @@ public function bool CreateRepInfo(Controller C)
if (RepInfo == None) return false;
RepInfo.PrepareSync(Self, KFPlayerController(C), LogLevel, DLCSkinUpdateRequired.Value, bApplyPatch);
RepInfos.AddItem(RepInfo);
if (ReadyToSync)
{
RepInfo.PrepareSync(Self, LogLevel, KFGI.KFGFxManagerClass, DLCSkinUpdateRequired.Value, bApplyPatch);
RepInfo.Replicate(WeapDefs);
}
else

View File

@ -23,8 +23,9 @@ private function CTI_GFxObject_TraderItems GetCTI_TraderItems()
private function CTI_InventoryManager GetCTI_IM()
{
if (CTI_IM == None)
if (CTI_IM != Pawn.InvManager)
{
`Log_Base("Update InvManager:" @ String(CTI_IM) @ "<-" @ String(Pawn.InvManager));
CTI_IM = CTI_InventoryManager(Pawn.InvManager);
}

View File

@ -1,5 +1,18 @@
class CTI_InventoryManager extends KFInventoryManager;
var private CTI_RepInfo RepInfo;
public function Initialize(CTI_RepInfo _RepInfo)
{
RepInfo = _RepInfo;
}
public function OwnerDied()
{
RepInfo.SetTimer(1.0f, false, nameof(RepInfo.InitInventoryManager));
Super.OwnerDied();
}
// simulated function final BuyAmmo( float AmountPurchased, EItemType ItemType, optional byte ItemIndex, optional bool bSecondaryAmmo )
public simulated function CTI_BuyAmmo(float AmountPurchased, EItemType ItemType, optional int ItemIndex, optional bool bSecondaryAmmo)
{
@ -457,6 +470,35 @@ private reliable server function CTI_ServerBuyGrenade(int AmountPurchased)
}
}
public simulated function int GetWeaponBlocks(const out STraderItem ShopItem, optional int OverrideLevelValue = INDEX_NONE)
{
local int ItemUpgradeLevel;
local KFPlayerController KFPC;
local Inventory InventoryItem;
if (ShopItem.SingleClassName != '' && OverrideLevelValue == INDEX_NONE && ClassNameIsInInventory(ShopItem.SingleClassName, InventoryItem))
{
ItemUpgradeLevel = KFWeapon(InventoryItem).CurrentWeaponUpgradeIndex;
}
else
{
if (OverrideLevelValue != INDEX_NONE)
{
ItemUpgradeLevel = OverrideLevelValue;
}
else
{
KFPC = KFPlayerController(Instigator.Owner);
if (KFPC != None)
{
ItemUpgradeLevel = KFPC.GetPurchaseHelper().GetItemUpgradeLevelByClassName(ShopItem.ClassName);
}
}
}
return ShopItem.BlocksRequired + (ItemUpgradeLevel > INDEX_NONE ? ShopItem.WeaponUpgradeWeight[ItemUpgradeLevel] : 0);
}
defaultproperties
{

View File

@ -23,6 +23,8 @@ var public bool PendingSync;
var private CTI CTI;
var private E_LogLevel LogLevel;
var private class<KFGFxMoviePlayer_Manager> FrontEndClass;
var private GameReplicationInfo GRI;
var private KFPlayerController KFPC;
var private KFPlayerReplicationInfo KFPRI;
@ -49,7 +51,7 @@ var private bool ClientReady, ServerReady;
replication
{
if (bNetInitial && Role == ROLE_Authority)
LogLevel, SkinUpdateRequired, PatchRequired;
LogLevel, SkinUpdateRequired, PatchRequired, FrontEndClass;
}
public simulated function bool SafeDestroy()
@ -60,24 +62,50 @@ public simulated function bool SafeDestroy()
}
public function PrepareSync(
CTI _CTI, KFPlayerController _KFPC, E_LogLevel _LogLevel,
CTI _CTI, E_LogLevel _LogLevel,
class<KFGFxMoviePlayer_Manager> _FrontEndClass,
bool _SkinUpdateRequired, bool _PatchRequired)
{
`Log_Trace();
CTI = _CTI;
KFPC = _KFPC;
LogLevel = _LogLevel;
FrontEndClass = _FrontEndClass;
SkinUpdateRequired = _SkinUpdateRequired;
PatchRequired = _PatchRequired;
}
private reliable client function ClientSetFrontEnd()
{
if (FrontEndClass == None || GetKFPRI() == None)
{
`Log_Debug("Wait for frontend");
SetTimer(1.0f, false, nameof(ClientSetFrontEnd));
return;
}
if (KFPC.MyGFxManager != None && KFPC.MyGFxManager.class == FrontEndClass)
{
`Log_Debug("MyGFxManager is ok:" @ String(KFPC.MyGFxManager.class));
return;
}
KFPC.MyGFxManager.CloseMenus(true);
KFPC.MyGFxManager = None;
KFPC.ClientSetFrontEnd(FrontEndClass, KFPRI.bOnlySpectator);
`Log_Debug(String(FrontEndClass) @ "initialized.");
}
public function Replicate(const out Array<class<KFWeaponDefinition> > WeapDefs)
{
`Log_Trace();
ServerReady = !PatchRequired;
ClientSetFrontEnd();
if (PatchRequired)
{
if (GetKFPC() != None)
@ -92,14 +120,15 @@ public function Replicate(const out Array<class<KFWeaponDefinition> > WeapDefs)
RepArray = WeapDefs;
RepData.Size = RepArray.Length;
if (WorldInfo.NetMode == NM_StandAlone)
if (WorldInfo.NetMode != NM_StandAlone)
{
Progress(RepArray.Length, RepArray.Length);
return;
}
Sync();
}
else
{
Finished();
}
}
private reliable server function Sync()
{
@ -179,7 +208,10 @@ private simulated function Finished()
if (KFGRI != None)
{
`Log_Debug("Finished: Trader.static.OverwriteTraderItems");
if (WorldInfo.NetMode != NM_StandAlone)
{
Trader.static.OverwriteTraderItems(KFGRI, RepArray, PatchRequired, LogLevel);
}
`Log_Info("Trader items successfully synchronized!");
}
else
@ -414,6 +446,12 @@ private reliable server function Cleanup()
{
`Log_Trace();
if (PatchRequired)
{
`Log_Debug("Skip cleanup to keep CTI_RepInfo alive");
return;
}
`Log_Debug("Cleanup" @ GetKFPC() @ GetKFPRI() == None? "" : GetKFPRI().PlayerName);
if (!CTI.DestroyRepInfo(GetKFPC()))
{
@ -434,7 +472,7 @@ public function InitInventoryManager()
`Log_Trace();
if (GetKFPRI() == None || !KFPRI.bHasSpawnedIn)
if (GetKFPRI() == None || !KFPRI.bHasSpawnedIn || KFPC.Pawn == None)
{
`Log_Debug("Wait for spawn (InventoryManager)");
SetTimer(1.0f, false, nameof(InitInventoryManager));
@ -445,6 +483,7 @@ public function InitInventoryManager()
KFPC.Pawn.InventoryManagerClass = InventoryManager;
NextInventoryManger = Spawn(KFPC.Pawn.InventoryManagerClass, KFPC.Pawn);
CTI_InventoryManager(NextInventoryManger).Initialize(Self);
if (NextInventoryManger == None)
{

View File

@ -2,7 +2,7 @@ class RemoveItems extends Object
dependson(CTI)
config(CTI);
var public config bool bAll;
var public config bool bALL;
var public config bool bHRG;
var public config bool bDLC;
var private config Array<String> Item;
@ -29,11 +29,11 @@ public static function InitConfig(int Version, int LatestVersion)
private static function ApplyDefault()
{
default.bAll = false;
default.bALL = false;
default.bHRG = false;
default.bDLC = false;
default.Item.Length = 0;
default.Item.AddItem("KFGame.KFWeapDef_9mmDual");
default.Item.AddItem("KFGame.SomeWeapon");
}
public static function Array<class<KFWeaponDefinition> > Load(E_LogLevel LogLevel)
@ -45,7 +45,7 @@ public static function Array<class<KFWeaponDefinition> > Load(E_LogLevel LogLeve
local int Line;
`Log_Info("Load items to remove:");
if (default.bAll)
if (default.bALL)
{
`Log_Info("Remove all default items");
}

BIN
Localization/CHN/CTI.chn Normal file

Binary file not shown.

BIN
Localization/CHT/CTI.cht Normal file

Binary file not shown.

View File

@ -20,15 +20,17 @@ No. This mod is not whitelisted and will de-rank your server. Any XP gained will
[h1]Usage (single player)[/h1]
[olist]
[*]Subscribe to this mutator;
[*]Start KF2;
[*]Create a file [b](*)[/b]: [b]C:\Users\<username>\Documents\My Games\KillingFloor2\KFGame\Config\KFCTI.ini[/b]
with the following content:
[b][CTI.CTI]
Version=0[/b]
[*]Open console (~) and input:
[*]Start KF2;
[*]Open console (~) and start any map with CTI (this will generate the default KFCTI.ini content):
[b]open KF-BioticsLab?Mutator=CTI.Mut[/b]
(replace the map and add the parameters you need)
[*]<Enter>.
[*]Close the game and configure CTI as you need (see the [b]Setup (KFCTI.ini)[/b] section below);
[*]Start KF2, open the console, start the game:
[b]open KF-BioticsLab?Mutator=CTI.Mut[/b]
(replace the map and add the parameters you need).
[/olist]
[h1]Usage (server)[/h1]
[b]Note:[/b] [i]If you don't understand what is written here, read the article [url=https://wiki.killingfloor2.com/index.php?title=Dedicated_Server_(Killing_Floor_2)][u]Dedicated Server (KF2 wiki)[/u][/url] before following these instructions.[/i]
@ -40,15 +42,18 @@ Version=0[/b]
[*]Add the following string to the [b][OnlineSubsystemSteamworks.KFWorkshopSteamworks][/b] section (create one if it doesn't exist):
[b]ServerSubscribedWorkshopItems=2830826239[/b]
[*]Start the server and wait while the mutator is downloading;
[*]When the download is complete, close the server;
[*]Create a file [b](*)[/b]: [b]<kf2-server>\KFGame\Config\KFCTI.ini[/b]
with the following content:
[b][CTI.CTI]
Version=0[/b]
[*]Add mutator to server start parameters: [b]?Mutator=CTI.Mut[/b] and restart the server.
[*]Add mutator to server start parameters: [b]?Mutator=CTI.Mut[/b] and start the server (this will generate the default KFCTI.ini content);
[*]Close the server and configure CTI as you need (see the [b]Setup (KFCTI.ini)[/b] section below);
[*]Start the server (with [b]?Mutator=CTI.Mut[/b]) again.
[/olist]
[h1][b](*)[/b] Buggy config variables initialization[/h1]
CTI, like many other mutators, initializes the config by relying on the unreal script feature which uses default values for each data type that is not explicitly specified. For the int type (which is used to store the config version) this is zero - detecting zero allows to understand that the mutator is being used for the first time (which means it's need to generate a config). But now the game contains a bug that initializes the config values randomly if they are not explicitly set. Thus, the config may have incorrect values or not be created at all. This is why I recommend explicitly set Version=0 in the config for the first time.
CTI, like many other mutators, initializes the config by relying on the unreal script feature which uses default values for each data type that is not explicitly specified. For the int type (which is used to store the config version) this is zero - detecting zero allows to understand that the mutator is being used for the first time (which means it's need to generate a config). But now the game contains a bug that initializes the config values randomly if they are not explicitly set. Thus, the config may have incorrect values or not be created at all. This is why I recommend explicitly set [b]Version=0[/b] in the config for the first time.
Unfortunately I can't do anything about it because it's a game problem (not mutator). I hope TWI fixes this someday.
@ -56,11 +61,11 @@ Unfortunately I can't do anything about it because it's a game problem (not muta
[list]
[*][b]bDisableItemLimitCheck[/b]: The original game does not support more than 256 trader items, adding items above this limit causes bugs. If this problem is solved (For example, if you are using a mutator that has already fixed this problem or by enabling [b]bApplyPatch[/b]) then it can be set [b]bDisableItemLimitCheck=True[/b] to remove the limit, otherwise it is better to leave it [b]False[/b].
[*]Set [b]bApplyPatch=True[/b] to fix some base classes of the game: this fixes problems when adding more than 256 items to a trader and will allow players to sell weapons that have been removed from trader inventory. Note that enabling this parameter replaces the following classes: KFAutoPurchaseHelper, KFInventoryManager, KFGFxMenu_Trader, KFGFxObject_TraderItems. There may be compatibility issues with mutators that also replace them.
[*]Set [b]bApplyPatch=True[/b] to fix some base classes of the game: this fixes problems when adding more than 256 items to a trader and will allow players to sell weapons that have been removed from trader inventory. Note that enabling this parameter replaces the following classes: [b]KFAutoPurchaseHelper[/b], [b]KFInventoryManager[/b], [b]KFGFxMenu_Trader[/b], [b]KFGFxObject_TraderItems[/b]. There may be compatibility issues with mutators that also replace them.
[*]Set [b]bPreloadContent=True[/b] to load weapon models in advance and have no lags during the game. In some cases (usually if there is a lot of custom content), enabling preload can cause models to disappear. It is recommended to test how this setting affects the game for your server configuration and then decide whether to enable preloading or not.
[*]Set [b]bPreloadContent=True[/b] to load weapon models in advance and have no lags when someone buys weapons. In some cases (usually if there is a lot of custom content), enabling preload can cause models to disappear. It is recommended to test how this setting affects the game for your server configuration and then decide whether to enable preloading or not.
[*]Set [b]bOfficialWeaponsList=True[/b] to have an auto-updated list of all official weapons in the config (for a convenient copy-paste).
[*]Set [b]bOfficialWeaponsList=True[/b] to have an auto-updated list of all official weapons in the config (for a convenient copy-paste) or leave it [b]False[/b] if you want a clean config without unnecessary things.
[*]Set [b]UnlockDLC[/b] to customize DLC weapon unlocks. Here are the possible values:
[list]
@ -73,7 +78,7 @@ Unfortunately I can't do anything about it because it's a game problem (not muta
[*]Use [b][CTI.RemoveItems][/b] to remove items from the trader inventory.
example: [b]Item=KFGame.KFWeapDef_Mac10[/b] will remove MAC10 from sale.
[*]Set [b]bAll=True[/b] if you want to remove all items (can be useful if you want to set the entire sale list in the [b][CTI.AddItems][/b] section yourself).
[*]Set [b]bALL=True[/b] if you want to remove all items (can be useful if you want to set the entire sale list in the [b][CTI.AddItems][/b] section yourself).
[*]Set [b]bHRG=True[/b] to remove HRG items.
[*]Set [b]bDLC=True[/b] to remove DLC items.
@ -88,5 +93,8 @@ This is necessary to explicitly initialize the list (because of the bug I wrote
📌 Mutator does not contain custom weapons. You must have the required weapon packs in your subscriptions to be able to add them to the trader.
📌 If you are using this mutator to add weapons, you should [b]not[/b] use mutators from weapon packs (just having them in subscriptions is enough).
[h1]Translators:[/h1]
[url=https://steamcommunity.com/profiles/76561199126205919]cheungfatzong[/url] - Traditional [CHT] and Simplified [CHN] Chinese.
[h1]Sources[/h1]
[url=https://github.com/GenZmeY/KF2-CustomTraderInventory]https://github.com/GenZmeY/KF2-CustomTraderInventory[/url] [b](GNU GPLv3)[/b]