From bf19cfa7b7e8fc0e08a3eca32919ef1f016ea2ad Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 31 Dec 2023 23:47:42 +0300 Subject: [PATCH] add short alias for mutator --- PublicationContent/description.txt | 4 +- YAS/Classes/Mut.uc | 60 +++++++++++++++++++++++++++++ YAS/Classes/YASMut.uc | 61 +----------------------------- 3 files changed, 63 insertions(+), 62 deletions(-) create mode 100644 YAS/Classes/Mut.uc diff --git a/PublicationContent/description.txt b/PublicationContent/description.txt index 3f49737..cdd2cb1 100644 --- a/PublicationContent/description.txt +++ b/PublicationContent/description.txt @@ -15,7 +15,7 @@ https://forums.tripwireinteractive.com/index.php?threads/whitelisting-mods-and-m [*]Subscribe to this mutator; [*]Start KF2; [*]Open console (`) and input: -[b]open KF-BioticsLab?Mutator=YAS.YASMut?[/b] +[b]open KF-BioticsLab?Mutator=YAS.Mut?[/b] (replace the map and add the parameters you need) [*]. [/olist] @@ -30,7 +30,7 @@ https://forums.tripwireinteractive.com/index.php?threads/whitelisting-mods-and-m [*]Add the following string to the [b][OnlineSubsystemSteamworks.KFWorkshopSteamworks][/b] section (create one if it doesn't exist): [b]ServerSubscribedWorkshopItems=2521826524[/b] [*]Start the server and wait until the mutator is downloading; -[*]Add mutator to server start parameters: [b]?Mutator=YAS.YASMut[/b] and restart the server. +[*]Add mutator to server start parameters: [b]?Mutator=YAS.Mut[/b] and restart the server. [/olist] [h1]Important setup information[/h1] diff --git a/YAS/Classes/Mut.uc b/YAS/Classes/Mut.uc new file mode 100644 index 0000000..e7aef68 --- /dev/null +++ b/YAS/Classes/Mut.uc @@ -0,0 +1,60 @@ +class Mut extends KFMutator; + +var private YAS YAS; + +public simulated function bool SafeDestroy() +{ + return (bPendingDelete || bDeleteMe || Destroy()); +} + +public event PreBeginPlay() +{ + Super.PreBeginPlay(); + + if (WorldInfo.NetMode == NM_Client) return; + + foreach WorldInfo.DynamicActors(class'YAS', YAS) + { + break; + } + + if (YAS == None) + { + YAS = WorldInfo.Spawn(class'YAS'); + } + + if (YAS == None) + { + `Log_Base("FATAL: Can't Spawn 'YAS'"); + SafeDestroy(); + } +} + +public function AddMutator(Mutator M) +{ + if (M == Self) return; + + if (M.Class == Class) + Mut(M).SafeDestroy(); + else + Super.AddMutator(M); +} + +public function NotifyLogin(Controller C) +{ + YAS.NotifyLogin(C); + + Super.NotifyLogin(C); +} + +public function NotifyLogout(Controller C) +{ + YAS.NotifyLogout(C); + + Super.NotifyLogout(C); +} + +DefaultProperties +{ + GroupNames.Add("Scoreboard") +} \ No newline at end of file diff --git a/YAS/Classes/YASMut.uc b/YAS/Classes/YASMut.uc index f61d997..115ecd8 100644 --- a/YAS/Classes/YASMut.uc +++ b/YAS/Classes/YASMut.uc @@ -1,60 +1 @@ -class YASMut extends KFMutator; - -var private YAS YAS; - -public simulated function bool SafeDestroy() -{ - return (bPendingDelete || bDeleteMe || Destroy()); -} - -public event PreBeginPlay() -{ - Super.PreBeginPlay(); - - if (WorldInfo.NetMode == NM_Client) return; - - foreach WorldInfo.DynamicActors(class'YAS', YAS) - { - break; - } - - if (YAS == None) - { - YAS = WorldInfo.Spawn(class'YAS'); - } - - if (YAS == None) - { - `Log_Base("FATAL: Can't Spawn 'YAS'"); - SafeDestroy(); - } -} - -public function AddMutator(Mutator Mut) -{ - if (Mut == Self) return; - - if (Mut.Class == Class) - YASMut(Mut).SafeDestroy(); - else - Super.AddMutator(Mut); -} - -public function NotifyLogin(Controller C) -{ - YAS.NotifyLogin(C); - - Super.NotifyLogin(C); -} - -public function NotifyLogout(Controller C) -{ - YAS.NotifyLogout(C); - - Super.NotifyLogout(C); -} - -DefaultProperties -{ - GroupNames.Add("Scoreboard") -} \ No newline at end of file +class YASMut extends Mut; // backward compatibility