12 Commits

Author SHA1 Message Date
7a6fca9462 fix SafeMutLoader::PostBeginPlay() initialization
- this fixes the players list in steam server browser -> server details.
2023-03-30 01:38:00 +03:00
e2ea9d5f2a Merge branch 'serveractors' 2023-03-02 05:18:04 +03:00
6e048463f6 dont add server actor twice 2023-03-02 05:07:19 +03:00
62f3421cb1 fix webadmin 2023-03-02 03:33:50 +03:00
68de02c9c8 Update README.md
Update information about Unofficial Killing Floor 2 Patch (now fully compatible)
2023-03-02 03:18:47 +03:00
4367cd2b15 add server actors support 2023-03-02 03:01:14 +03:00
f6e1a27d95 Update description.txt 2022-11-27 20:23:02 +03:00
9236bd8387 Update README.md 2022-11-27 20:22:18 +03:00
a9be5a77d6 Update DEV.md 2022-11-27 20:20:48 +03:00
3f6c3552d1 Update DEV.md 2022-11-26 21:22:51 +03:00
e92a146660 Update README.md 2022-11-26 19:26:16 +03:00
22d4c40c53 update unnoficial patch info 2022-11-26 18:34:41 +03:00
6 changed files with 203 additions and 12 deletions

4
DEV.md
View File

@ -46,7 +46,7 @@ public function AddMutator(Mutator Mut)
if (Mut == Self) return; if (Mut == Self) return;
if (Mut.Class == Class) if (Mut.Class == Class)
Mut.Destroy(); ExampleMut(Mut).SafeDestroy();
else else
Super.AddMutator(Mut); Super.AddMutator(Mut);
} }
@ -127,7 +127,7 @@ That's all. You can create new classes and add any code to `Example.uc` (yay!),
# Tips # Tips
## Alternative to the InitMutator(...) function ## Alternative to the InitMutator(...) function
Even though the [`InitMutator(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/KFGame/Classes/KFMutator.uc#L22) function is not supported, you can still parse the startup string if you need to: Even though the [`InitMutator(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/KFGame/Classes/KFMutator.uc#L22) function is not supported, you can still parse the startup string if you need to:
Refer to [`WorldInfo.Game.ServerOptions`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/Engine/Classes/GameInfo.uc#L209) or [`WorldInfo.GetLocalURL()`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/Engine/Classes/WorldInfo.uc#L1315) and get the option from there. It's best to do this in `PreBeginPlay()` or `PostBeginPlay()` of your `Example.uc` (as well as other initializations). Refer to [`WorldInfo.GetLocalURL()`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/Engine/Classes/WorldInfo.uc#L1315) and get the option from there. It's best to do this in `PreBeginPlay()` or `PostBeginPlay()` of your `Example.uc` (as well as other initializations).
## XP for custom Zeds / Weapons ## XP for custom Zeds / Weapons
While custom weapons and zeds won't make your server unranked, the [`ValidateForXP(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/KFGame/Classes/KFGameInfo.uc#L2564) function will not allow you to gain experience if it detects a custom zed or custom damage type. While custom weapons and zeds won't make your server unranked, the [`ValidateForXP(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/KFGame/Classes/KFGameInfo.uc#L2564) function will not allow you to gain experience if it detects a custom zed or custom damage type.

View File

@ -26,7 +26,11 @@
[*]Since [url=https://wiki.killingfloor2.com/index.php?title=Update_1133_(Killing_Floor_2)]KF2 v1133[/url] the content preload causes the server to unrank for some reason. Disable it in CTI settings ([b]bPreloadContent=False[/b]) to stay ranked. [*]Since [url=https://wiki.killingfloor2.com/index.php?title=Update_1133_(Killing_Floor_2)]KF2 v1133[/url] the content preload causes the server to unrank for some reason. Disable it in CTI settings ([b]bPreloadContent=False[/b]) to stay ranked.
[/list] [/list]
🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2891475864]Discord Link [Edited][/url] 🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2891475864]Discord Link [Edited][/url]
🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2875147606]Unofficial Killing Floor 2 Patch[/url] 🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2864857909]Looted Trader Inventory[/url]
🟡 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2875147606]Unofficial Killing Floor 2 Patch[/url]
[list]
[*]Settings are not available (config and start parameters are ignored), patch will work with default settings
[/list]
🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2521826524]Yet Another Scoreboard[/url] 🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2521826524]Yet Another Scoreboard[/url]
🟡 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2811290931]Zed Spawner[/url] 🟡 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2811290931]Zed Spawner[/url]
[list] [list]

View File

@ -11,7 +11,7 @@ However, [AccessPlus](https://forums.tripwireinteractive.com/index.php?threads/u
# Usage (server only) # Usage (server only)
1. Add SML to your server. There are two ways: 1. Add SML to your server. There are two ways:
* **without workshop:** download `SML.u` from [releases](https://github.com/GenZmeY/KF2-SafeMutLoader/releases) and put it to `KFGame/BrewedPC` * **without workshop:** download `SML.u` from [releases](https://github.com/GenZmeY/KF2-SafeMutLoader/releases) and put it to `KFGame/BrewedPC`
* **with workshop:** Use the instructions below to build the SML and upload it to your workshop, then subscribe your server to SML * **with workshop:** Use the [instructions below](https://github.com/GenZmeY/KF2-SafeMutLoader#build--upload) to build the SML and upload it to your workshop, then subscribe your server to SML
2. Add `SML.Mut` **first** to your list of mutators, example: 2. Add `SML.Mut` **first** to your list of mutators, example:
``` ```
?Mutator=SML.Mut,UnofficialKFPatch.UKFPMutator,AAL.AALMut,DiscordMessage.DMMutator,YAS.YASMut,CTI.CTIMut,CVC.CVCMut,ZedSpawner.ZedSpawnerMut ?Mutator=SML.Mut,UnofficialKFPatch.UKFPMutator,AAL.AALMut,DiscordMessage.DMMutator,YAS.YASMut,CTI.CTIMut,CVC.CVCMut,ZedSpawner.ZedSpawnerMut
@ -32,6 +32,7 @@ However, [AccessPlus](https://forums.tripwireinteractive.com/index.php?threads/u
Purchasing a DLC weapon will unrank the server if currently there is no player with the purchased DLC. This can be bypassed by replacing all DLC weapons with their clones. Purchasing a DLC weapon will unrank the server if currently there is no player with the purchased DLC. This can be bypassed by replacing all DLC weapons with their clones.
Since KF2 [v1133](https://wiki.killingfloor2.com/index.php?title=Update_1133_(Killing_Floor_2)) the content preload causes the server to unrank for some reason. Disable it in CTI settings (`bPreloadContent=False`) to stay ranked. Since KF2 [v1133](https://wiki.killingfloor2.com/index.php?title=Update_1133_(Killing_Floor_2)) the content preload causes the server to unrank for some reason. Disable it in CTI settings (`bPreloadContent=False`) to stay ranked.
🟢 [Discord Link [Edited]](https://steamcommunity.com/sharedfiles/filedetails/?id=2891475864) 🟢 [Discord Link [Edited]](https://steamcommunity.com/sharedfiles/filedetails/?id=2891475864)
🟢 [Looted Trader Inventory](https://steamcommunity.com/sharedfiles/filedetails/?id=2864857909)
🟢 [Unofficial Killing Floor 2 Patch](https://steamcommunity.com/sharedfiles/filedetails/?id=2875147606) 🟢 [Unofficial Killing Floor 2 Patch](https://steamcommunity.com/sharedfiles/filedetails/?id=2875147606)
🟢 [Yet Another Scoreboard](https://steamcommunity.com/sharedfiles/filedetails/?id=2521826524) 🟢 [Yet Another Scoreboard](https://steamcommunity.com/sharedfiles/filedetails/?id=2521826524)
🟡 [Zed Spawner](https://steamcommunity.com/sharedfiles/filedetails/?id=2811290931) 🟡 [Zed Spawner](https://steamcommunity.com/sharedfiles/filedetails/?id=2811290931)

View File

@ -0,0 +1,11 @@
class KFGI_Access extends Object within KFGameInfo;
public function bool IsRankedGame()
{
return !IsUnrankedGame();
}
defaultproperties
{
}

View File

@ -32,9 +32,13 @@ public function AddMutator(Mutator Mut)
if (CorrectLoadOrder() || Mut == Self) return; if (CorrectLoadOrder() || Mut == Self) return;
if (Mut.Class == Class) if (Mut.Class == Class)
{
Mut.Destroy(); Mut.Destroy();
}
else else
{
Super.AddMutator(Mut); Super.AddMutator(Mut);
}
} }
private function bool CorrectLoadOrder() private function bool CorrectLoadOrder()
@ -53,7 +57,9 @@ private function ModifyLoad()
local String MutatorsRaw; local String MutatorsRaw;
local String AccessControlRaw; local String AccessControlRaw;
local Array<String> Mutators; local Array<String> Mutators;
local int PrevServerActorsCount;
local int Index; local int Index;
local GameEngine GameEngine;
`Log_Trace(); `Log_Trace();
@ -66,6 +72,7 @@ private function ModifyLoad()
LoadURL = Repl(LoadURL, Subst(OptAC) $ AccessControlRaw, ""); LoadURL = Repl(LoadURL, Subst(OptAC) $ AccessControlRaw, "");
SML.static.ClearMutators(); SML.static.ClearMutators();
SML.static.ClearServerActors();
ParseStringIntoArray(MutatorsRaw, Mutators, ",", true); ParseStringIntoArray(MutatorsRaw, Mutators, ",", true);
Index = 0; Index = 0;
@ -81,6 +88,35 @@ private function ModifyLoad()
++Index; ++Index;
} }
} }
GameEngine = GameEngine(Class'Engine'.static.GetEngine());
if (GameEngine == None)
{
`Log_Error("GameEngine is None, skip loading server actors");
}
else
{
PrevServerActorsCount = GameEngine.ServerActors.Length;
Index = 0;
while (Index < GameEngine.ServerActors.Length)
{
if (SML.static.AddServerActor(GameEngine.ServerActors[Index]))
{
GameEngine.ServerActors.Remove(Index, 1);
}
else
{
++Index;
}
}
if (GameEngine.ServerActors.Length != PrevServerActorsCount)
{
GameEngine.SaveConfig();
}
}
SML.static.StaticSaveConfig(); SML.static.StaticSaveConfig();
JoinArray(Mutators, MutatorsRaw); JoinArray(Mutators, MutatorsRaw);

View File

@ -7,23 +7,70 @@ struct CMR
var String Replacement; var String Replacement;
}; };
var private Array<Actor> ServerActors; var private Array<Actor> ActiveMutators;
var private Array<Actor> ActiveServerActors;
var private Array<CMR> CustomMutReplacements; var private Array<CMR> CustomMutReplacements;
var private Array<String> SystemServerActors;
var private config E_LogLevel LogLevel; var private config E_LogLevel LogLevel;
var private config Array<String> Mutators; var private config Array<String> Mutators;
var private config Array<String> ServerActors;
public function PreBeginPlay() public function PreBeginPlay()
{ {
`Log_Trace();
LogLevel = GetLogLevel(); LogLevel = GetLogLevel();
LoadActors(); `Log_Trace();
Super.PreBeginPlay(); Super.PreBeginPlay();
LoadMutators();
LoadServerActors();
} }
private function LoadActors() public function PostBeginPlay()
{
local KFGI_Access KFGIA;
`Log_Trace();
Super.PostBeginPlay();
RestoreServerActors();
KFGIA = GetKFGIA();
if (KFGIA == None)
{
`Log_Error("Can't check ranked status");
}
else if (KFGIA.IsRankedGame())
{
`Log_Info("Mutators and server actors successfully loaded! Your server is RANKED!");
}
else
{
`Log_Warn("Your server is UNRANKED! Check the mutators and server actors you are using. Maybe some of them are incompatible with SML");
}
}
private function KFGI_Access GetKFGIA()
{
local KFGameInfo KFGI;
if (WorldInfo == None || WorldInfo.Game == None)
{
return None;
}
KFGI = KFGameInfo(WorldInfo.Game);
if (KFGI == None)
{
return None;
}
return new(KFGI) class'KFGI_Access';
}
private function LoadMutators()
{ {
local String MutString; local String MutString;
local class<Mutator> MutClass; local class<Mutator> MutClass;
@ -55,11 +102,96 @@ private function LoadActors()
continue; continue;
} }
ServerActors.AddItem(ServerActor); ActiveMutators.AddItem(ServerActor);
`Log_Info("Loaded:" @ MutString); `Log_Info("Loaded:" @ MutString);
} }
} }
private function LoadServerActors()
{
local String ActorString;
local class<Actor> ActorClass;
local Actor ServerActor;
foreach ServerActors(ActorString)
{
ActorClass = class<Actor>(DynamicLoadObject(ActorString, class'Class'));
if (ActorClass == None)
{
`Log_Error("Can't load server actor:" @ ActorString);
continue;
}
ServerActor = WorldInfo.Spawn(ActorClass);
if (ServerActor == None)
{
`Log_Error("Can't spawn:" @ ActorString);
continue;
}
ActiveServerActors.AddItem(ServerActor);
`Log_Info("Loaded:" @ ActorString);
}
}
private function RestoreServerActors()
{
local GameEngine GameEngine;
local String ActorString;
local int PrevServerActorsCount;
GameEngine = GameEngine(Class'Engine'.static.GetEngine());
if (GameEngine == None)
{
`Log_Error("GameEngine is None! Can't restore ServerActors!");
return;
}
PrevServerActorsCount = GameEngine.ServerActors.Length;
foreach ServerActors(ActorString)
{
if (GameEngine.ServerActors.Find(ActorString) != INDEX_NONE)
{
GameEngine.ServerActors.AddItem(ActorString);
}
}
if (GameEngine.ServerActors.Length != PrevServerActorsCount)
{
GameEngine.SaveConfig();
}
}
public static function bool AddServerActor(String ServerActor)
{
local class<Actor> ActorClass;
if (default.SystemServerActors.Find(ServerActor) != INDEX_NONE)
{
return false;
}
ActorClass = class<Actor>(DynamicLoadObject(ServerActor, class'Class'));
if (ActorClass == None)
{
return false;
}
if (ClassIsChildOf(ActorClass, class'Mutator'))
{
return false;
}
if (default.ServerActors.Find(ServerActor) == INDEX_NONE)
{
default.ServerActors.AddItem(ServerActor);
}
return true;
}
public static function bool AddMutator(String MutString) public static function bool AddMutator(String MutString)
{ {
if (GetMutStringReplacement(MutString) != None) if (GetMutStringReplacement(MutString) != None)
@ -79,6 +211,11 @@ public static function ClearMutators()
default.Mutators.Length = 0; default.Mutators.Length = 0;
} }
public static function ClearServerActors()
{
default.ServerActors.Length = 0;
}
public static function bool WantsToSpawn() public static function bool WantsToSpawn()
{ {
return (default.Mutators.Length > 0); return (default.Mutators.Length > 0);
@ -111,7 +248,7 @@ public function PostLogin(PlayerController C)
if (C != None) if (C != None)
{ {
foreach ServerActors(A) foreach ActiveMutators(A)
{ {
A.GetTargetLocation(C, false); A.GetTargetLocation(C, false);
} }
@ -130,7 +267,7 @@ public function OnClientConnectionClose(Player ClientConnection)
C = ClientConnection.Actor; C = ClientConnection.Actor;
if (C != None) if (C != None)
{ {
foreach ServerActors(A) foreach ActiveMutators(A)
{ {
A.GetTargetLocation(C, true); A.GetTargetLocation(C, true);
} }
@ -189,4 +326,6 @@ defaultproperties
Mutator="UnofficialKFPatch.UKFPMutatorNW", Mutator="UnofficialKFPatch.UKFPMutatorNW",
Replacement="UnofficialKFPatch.UKFPReplicationInfo" Replacement="UnofficialKFPatch.UKFPReplicationInfo"
)}) )})
SystemServerActors.Add("IpDrv.WebServer")
} }