10 Commits

Author SHA1 Message Date
ac6e0a8977 fix 9mm/HRG93R filter 2023-10-21 13:59:58 +03:00
561545de2b a little cleaning 2023-10-20 23:48:04 +03:00
6dfbcbb0b7 force GRI init 2023-10-20 23:30:45 +03:00
18fc55ce42 force skin update 2023-10-20 23:18:04 +03:00
6cc67da26b Merge branch 'replace-dlc-weapons-fix' 2023-10-20 22:56:15 +03:00
dc2108e482 Merge pull request #10 from GenZmeY/Halloween2023Update
Halloween 2023 Update
2023-10-20 22:54:26 +03:00
37944a25c4 remove DLC clones along with their originals from [CTI.RemoveItems] 2023-10-20 22:53:11 +03:00
ce070b66cd Merge branch 'master' into Halloween2023Update 2023-10-05 21:40:07 +03:00
7e0151bf09 Merge branch 'linter' into Halloween2023Update 2023-10-05 20:21:21 +03:00
f4cfa4948b unlock MG3 2023-09-26 01:52:14 +03:00
8 changed files with 128 additions and 51 deletions

View File

@ -187,18 +187,7 @@ private function PostInit()
return;
}
if (Unlocker.static.UnlockDLC(KFGI, KFGRI, UnlockDLC, RemoveItems, AddItems, DLCSkinUpdateRequired, LogLevel))
{
`Log_Info("DLC unlocked");
}
`Log_Debug("DLCSkinUpdateRequired:" @ String(DLCSkinUpdateRequired.Value));
if (bPreloadContent)
{
Preload(AddItems);
}
Trader.static.ModifyTrader(
WeapDefs = Trader.static.GenerateWeapDefList(
KFGRI,
RemoveItems,
AddItems,
@ -208,7 +197,23 @@ private function PostInit()
bDisableItemLimitCheck,
LogLevel);
WeapDefs = Trader.static.GetTraderWeapDefs(KFGRI, LogLevel);
RemoveItems.Length = 0;
AddItems.Length = 0;
if (Unlocker.static.UnlockDLC(KFGI, KFGRI, UnlockDLC, WeapDefs, DLCSkinUpdateRequired, LogLevel))
{
`Log_Info("DLC unlocked");
}
`Log_Debug("DLCSkinUpdateRequired:" @ String(DLCSkinUpdateRequired.Value));
Trader.static.OverwriteTraderItems(KFGRI, WeapDefs, LogLevel);
`Log_Info("Trader items:" @ WeapDefs.Length);
if (bPreloadContent)
{
Preload(WeapDefs);
}
ReadyToSync = true;

View File

@ -11,6 +11,17 @@ function bool IsItemFiltered(STraderItem Item, optional bool bDebug)
if (Item.WeaponDef.default.PlatformRestriction != PR_All && class'KFUnlockManager'.static.IsPlatformRestricted(Item.WeaponDef.default.PlatformRestriction))
return true;
if (Has9mmGun())
{
if ((Item.ClassName == 'KFWeap_HRG_93r' || Item.ClassName == 'KFWeap_HRG_93r_Dual'))
return true;
}
else
{
if ((Item.ClassName == 'KFWeap_Pistol_9mm' || Item.ClassName == 'KFWeap_Pistol_Dual9mm'))
return true;
}
return false;
}

View File

@ -21,6 +21,7 @@ var public bool PendingSync;
var private CTI CTI;
var private E_LogLevel LogLevel;
var private GameReplicationInfo GRI;
var private KFPlayerController KFPC;
var private KFPlayerReplicationInfo KFPRI;
var private KFGFxWidget_PartyInGame PartyInGameWidget;
@ -32,6 +33,7 @@ var private String NotificationRightText;
var private int NotificationPercent;
var private int WaitingGRI;
var private int WaitingGRIThreshold;
var private int WaitingGRILimit;
var private ReplicationStruct RepData;
@ -138,7 +140,7 @@ private simulated function Finished()
`Log_Trace();
if (WorldInfo.GRI == None && WaitingGRI++ < WaitingGRILimit)
if (GetGRI(WaitingGRI > WaitingGRIThreshold) == None && WaitingGRI++ < WaitingGRILimit)
{
`Log_Debug("Finished: Waiting GRI" @ WaitingGRI);
NotifyWaitingGRI();
@ -146,7 +148,7 @@ private simulated function Finished()
return;
}
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
KFGRI = KFGameReplicationInfo(GRI);
if (KFGRI != None)
{
`Log_Debug("Finished: Trader.static.OverwriteTraderItems");
@ -155,7 +157,7 @@ private simulated function Finished()
}
else
{
`Log_Error("Incompatible Replication info:" @ String(WorldInfo.GRI));
`Log_Error("Incompatible Replication info:" @ String(GRI));
NotifyIncompatibleGRI();
}
@ -180,7 +182,13 @@ private simulated function UpdateSkinsDLC()
{
foreach Replacements.default.DLC(WeapReplace)
{
if (WeapReplace.WeapParent.default.SkinItemId > 0 && WeapReplace.Weap.default.SkinItemId != WeapReplace.WeapParent.default.SkinItemId)
// sometimes "WeapReplace.Weap.default.SkinItemId" can give values greater than zero while actually being zero
// this is the same bug that prevents creating the correct default config
// so for now lets shorten the check a little so that the skinId of the WeapReplace is guaranteed to be correct
// but if this bug is ever fixed, then its worth replacing the check with this one:
// if (WeapReplace.WeapParent.default.SkinItemId > 0 && WeapReplace.Weap.default.SkinItemId != WeapReplace.WeapParent.default.SkinItemId)
// to reduce the number of meaningless disk writes
if (WeapReplace.WeapParent.default.SkinItemId > 0)
{
`Log_Debug("Update skin for:" @ String(WeapReplace.WeapDef) @ "SkinId:" @ WeapReplace.WeapParent.default.SkinItemId);
class'KFWeaponSkinList'.static.SaveWeaponSkin(WeapReplace.WeapDef, WeapReplace.WeapParent.default.SkinItemId);
@ -192,6 +200,29 @@ private simulated function UpdateSkinsDLC()
}
}
private simulated function GameReplicationInfo GetGRI(optional bool ForcedSearch = false)
{
`Log_Trace();
if (GRI == None)
{
GRI = WorldInfo.GRI;
}
if (GRI == None && ForcedSearch)
{
foreach WorldInfo.DynamicActors(class'GameReplicationInfo', GRI) break;
}
if (WorldInfo.GRI == None && GRI != None)
{
`Log_Warn("Force initialization of WorldInfo.GRI" @ String(GRI));
WorldInfo.GRI = GRI;
}
return GRI;
}
private simulated function KFPlayerController GetKFPC()
{
`Log_Trace();
@ -332,6 +363,7 @@ private simulated function KeepNotification()
private simulated function ClientCleanup()
{
`Log_Debug("Cleanup");
ServerCleanup();
SafeDestroy();
}
@ -340,7 +372,7 @@ private reliable server function ServerCleanup()
{
`Log_Trace();
`Log_Debug("Cleanup");
`Log_Debug("Cleanup" @ GetKFPC() @ GetKFPRI() == None? "" : GetKFPRI().PlayerName);
if (!CTI.DestroyRepInfo(GetKFPC()))
{
`Log_Debug("Cleanup (forced)");
@ -381,7 +413,7 @@ private simulated function NotifyIncompatibleGRI()
WriteToChatLocalized(
CTI_IncompatibleGRI,
class'KFLocalMessage'.default.InteractionColor,
String(WorldInfo.GRI.class));
String(GRI.class));
WriteToChatLocalized(
CTI_IncompatibleGRIWarning,
class'KFLocalMessage'.default.InteractionColor);
@ -397,5 +429,6 @@ defaultproperties
NotificationPercent = 0
WaitingGRI = 0
WaitingGRIThreshold = 15
WaitingGRILimit = 30
}

View File

@ -0,0 +1,13 @@
class CTI_WeapDef_MG3 extends KFWeapDef_MG3
abstract;
static function String GetItemLocalization(String KeyName)
{
return class'KFGame.KFWeapDef_MG3'.static.GetItemLocalization(KeyName);
}
defaultproperties
{
SharedUnlockId = SCU_None
WeaponClassPath = "CTI.CTI_Weap_LMG_MG3"
}

View File

@ -0,0 +1,6 @@
class CTI_Weap_LMG_MG3 extends KFWeap_LMG_MG3;
defaultproperties
{
}

View File

@ -91,11 +91,11 @@ public static function Array<class<KFWeaponDefinition> > GetTraderWeapDefsDLC(KF
return WeapDefs;
}
public static simulated function ModifyTrader(
public static simulated function Array< class<KFWeaponDefinition> > GenerateWeapDefList(
KFGameReplicationInfo KFGRI,
const out Array<class<KFWeaponDefinition> > RemoveItems,
const out Array<class<KFWeaponDefinition> > AddItems,
bool ReplaceMode,
bool RemoveAll,
bool RemoveHRG,
bool RemoveDLC,
bool bDisableItemLimitCheck,
@ -103,14 +103,14 @@ public static simulated function ModifyTrader(
{
local KFGFxObject_TraderItems TraderItems;
local STraderItem Item;
local Array<class<KFWeaponDefinition> > WeapDefs;
local Array< class<KFWeaponDefinition> > WeapDefs;
local int Index;
`Log_TraceStatic();
TraderItems = GetTraderItems(KFGRI, LogLevel);
if (!ReplaceMode)
if (!RemoveAll)
{
foreach TraderItems.SaleItems(Item)
{
@ -126,9 +126,12 @@ public static simulated function ModifyTrader(
}
for (Index = 0; Index < AddItems.Length; ++Index)
{
if (WeaponClassIsUnique(AddItems[Index].default.WeaponClassPath, WeapDefs, LogLevel))
{
WeapDefs.AddItem(AddItems[Index]);
}
}
WeapDefs.Sort(ByPrice);
@ -143,7 +146,7 @@ public static simulated function ModifyTrader(
WeapDefs.Length = ITEMS_LIMIT;
}
OverwriteTraderItems(KFGRI, WeapDefs, LogLevel);
return WeapDefs;
}
public static simulated function OverwriteTraderItems(

View File

@ -31,8 +31,7 @@ public static function bool UnlockDLC(
KFGameInfo KFGI,
KFGameReplicationInfo KFGRI,
String UnlockType,
out Array<class<KFWeaponDefinition> > RemoveItems,
out Array<class<KFWeaponDefinition> > AddItems,
out Array<class<KFWeaponDefinition> > WeapDefs,
out BoolWrapper DLCSkinUpdateRequired,
E_LogLevel LogLevel)
{
@ -42,11 +41,10 @@ public static function bool UnlockDLC(
{
case "true":
case "auto":
return Auto(KFGI, KFGRI, RemoveItems, AddItems, DLCSkinUpdateRequired, LogLevel);
return Auto(KFGI, KFGRI, WeapDefs, DLCSkinUpdateRequired, LogLevel);
case "replaceweapons":
DLCSkinUpdateRequired.Value = true;
return ReplaceWeapons(KFGRI, RemoveItems, AddItems, LogLevel);
return ReplaceWeapons(KFGRI, WeapDefs, DLCSkinUpdateRequired, LogLevel);
case "replacefilter":
DLCSkinUpdateRequired.Value = false;
@ -61,8 +59,7 @@ public static function bool UnlockDLC(
private static function bool Auto(
KFGameInfo KFGI,
KFGameReplicationInfo KFGRI,
out Array<class<KFWeaponDefinition> > RemoveItems,
out Array<class<KFWeaponDefinition> > AddItems,
out Array<class<KFWeaponDefinition> > WeapDefs,
out BoolWrapper DLCSkinUpdateRequired,
E_LogLevel LogLevel)
{
@ -83,8 +80,7 @@ private static function bool Auto(
if (CustomGFxManager)
{
DLCSkinUpdateRequired.Value = true;
return ReplaceWeapons(KFGRI, RemoveItems, AddItems, LogLevel);
return ReplaceWeapons(KFGRI, WeapDefs, DLCSkinUpdateRequired, LogLevel);
}
else
{
@ -95,14 +91,14 @@ private static function bool Auto(
private static function bool ReplaceWeapons(
KFGameReplicationInfo KFGRI,
out Array<class<KFWeaponDefinition> > RemoveItems,
out Array<class<KFWeaponDefinition> > AddItems,
out Array<class<KFWeaponDefinition> > WeapDefs,
out BoolWrapper DLCSkinUpdateRequired,
E_LogLevel LogLevel)
{
local Array<class<KFWeaponDefinition> > WeapDefsDLCs;
local class<KFWeaponDefinition> WeapDefDLC;
local class<KFWeaponDefinition> WeapDef;
local class<KFWeaponDefinition> WeapDefReplacement;
local bool Unlock, PartialUnlock;
local int Index;
`Log_TraceStatic();
@ -110,30 +106,34 @@ private static function bool ReplaceWeapons(
Unlock = false;
PartialUnlock = false;
DLCSkinUpdateRequired.Value = false;
WeapDefsDLCs = Trader.static.GetTraderWeapDefsDLC(KFGRI, LogLevel);
foreach WeapDefsDLCs(WeapDefDLC)
for (Index = 0; Index < WeapDefs.Length; Index++)
{
WeapDefReplacement = PickReplacementWeapDefDLC(WeapDefDLC, LogLevel);
WeapDef = WeapDefs[Index];
if (WeapDef.default.SharedUnlockId == SCU_None) continue;
WeapDefReplacement = PickReplacementWeapDefDLC(WeapDef, LogLevel);
if (WeapDefReplacement != None)
{
Unlock = true;
if (AddItems.Find(WeapDefReplacement) == INDEX_NONE)
DLCSkinUpdateRequired.Value = true;
if (WeapDefs.Find(WeapDefReplacement) == INDEX_NONE)
{
AddItems.AddItem(WeapDefReplacement);
WeapDefs[Index] = WeapDefReplacement;
`Log_Debug(WeapDef @ "replaced by" @ WeapDefReplacement);
}
else
{
WeapDefs.Remove(Index--, 1);
`Log_Debug("Skip already unlocked weapon:" @ WeapDef);
}
`Log_Debug(WeapDefDLC @ "replaced by" @ WeapDefReplacement);
}
else
{
PartialUnlock = true;
`Log_Warn("Can't unlock item:" @ WeapDefDLC @ "SharedUnlockId:" @ WeapDefDLC.default.SharedUnlockId);
}
if (RemoveItems.Find(WeapDefDLC) == INDEX_NONE)
{
RemoveItems.AddItem(WeapDefDLC);
`Log_Warn("Can't unlock item:" @ WeapDef @ "SharedUnlockId:" @ WeapDef.default.SharedUnlockId);
}
}

View File

@ -102,6 +102,12 @@ defaultproperties
Weap=class'CTI_Weap_Edged_IonThruster',
WeapParent=class'KFWeap_Edged_IonThruster'
)})
DLC.Add({(
WeapDef=class'CTI_WeapDef_MG3',
WeapDefParent=class'KFWeapDef_MG3',
Weap=class'CTI_Weap_LMG_MG3',
WeapParent=class'KFWeap_LMG_MG3'
)})
DLC.Add({(
WeapDef=class'CTI_WeapDef_Mine_Reconstructor',
WeapDefParent=class'KFWeapDef_Mine_Reconstructor',