From 07d8e161215242ecaf4e550073e19b905aed7845 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 31 Dec 2023 23:51:33 +0300 Subject: [PATCH] add short alias for mutator --- PublicationContent/description.txt | 4 +- ZedSpawner/Classes/Mut.uc | 61 ++++++++++++++++++++++++++++ ZedSpawner/Classes/ZedSpawnerMut.uc | 62 +---------------------------- 3 files changed, 64 insertions(+), 63 deletions(-) create mode 100644 ZedSpawner/Classes/Mut.uc diff --git a/PublicationContent/description.txt b/PublicationContent/description.txt index 6eab28b..cc252d7 100644 --- a/PublicationContent/description.txt +++ b/PublicationContent/description.txt @@ -18,7 +18,7 @@ No. This mod is not whitelisted and will de-rank your server. Any XP gained will [*]Subscribe to this mutator; [*]Start KF2; [*]Open console (~) and input: -[b]open KF-BioticsLab?Mutator=ZedSpawner.ZedSpawnerMut[/b] +[b]open KF-BioticsLab?Mutator=ZedSpawner.Mut[/b] (replace the map and add the parameters you need) [*]. [/olist] @@ -33,7 +33,7 @@ No. This mod is not whitelisted and will de-rank your server. Any XP gained will [*]Add the following string to the [b][OnlineSubsystemSteamworks.KFWorkshopSteamworks][/b] section (create one if it doesn't exist): [b]ServerSubscribedWorkshopItems=2811290931[/b] [*]Start the server and wait while the mutator is downloading; -[*]Add mutator to server start parameters: [b]?Mutator=ZedSpawner.ZedSpawnerMut[/b] and restart the server. +[*]Add mutator to server start parameters: [b]?Mutator=ZedSpawner.Mut[/b] and restart the server. [/olist] [h1]Important setup information[/h1] diff --git a/ZedSpawner/Classes/Mut.uc b/ZedSpawner/Classes/Mut.uc new file mode 100644 index 0000000..dc51b48 --- /dev/null +++ b/ZedSpawner/Classes/Mut.uc @@ -0,0 +1,61 @@ +class Mut extends KFMutator + dependson(ZedSpawner); + +var private ZedSpawner ZS; + +public simulated function bool SafeDestroy() +{ + return (bPendingDelete || bDeleteMe || Destroy()); +} + +public event PreBeginPlay() +{ + Super.PreBeginPlay(); + + if (WorldInfo.NetMode == NM_Client) return; + + foreach WorldInfo.DynamicActors(class'ZedSpawner', ZS) + { + break; + } + + if (ZS == None) + { + ZS = WorldInfo.Spawn(class'ZedSpawner'); + } + + if (ZS == None) + { + `Log_Base("FATAL: Can't Spawn 'ZedSpawner'"); + 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) +{ + ZS.NotifyLogin(C); + + Super.NotifyLogin(C); +} + +public function NotifyLogout(Controller C) +{ + ZS.NotifyLogout(C); + + Super.NotifyLogout(C); +} + +defaultproperties +{ + +} \ No newline at end of file diff --git a/ZedSpawner/Classes/ZedSpawnerMut.uc b/ZedSpawner/Classes/ZedSpawnerMut.uc index 65bb379..48f531d 100644 --- a/ZedSpawner/Classes/ZedSpawnerMut.uc +++ b/ZedSpawner/Classes/ZedSpawnerMut.uc @@ -1,61 +1 @@ -class ZedSpawnerMut extends KFMutator - dependson(ZedSpawner); - -var private ZedSpawner ZS; - -public simulated function bool SafeDestroy() -{ - return (bPendingDelete || bDeleteMe || Destroy()); -} - -public event PreBeginPlay() -{ - Super.PreBeginPlay(); - - if (WorldInfo.NetMode == NM_Client) return; - - foreach WorldInfo.DynamicActors(class'ZedSpawner', ZS) - { - break; - } - - if (ZS == None) - { - ZS = WorldInfo.Spawn(class'ZedSpawner'); - } - - if (ZS == None) - { - `Log_Base("FATAL: Can't Spawn 'ZedSpawner'"); - SafeDestroy(); - } -} - -public function AddMutator(Mutator Mut) -{ - if (Mut == Self) return; - - if (Mut.Class == Class) - ZedSpawnerMut(Mut).SafeDestroy(); - else - Super.AddMutator(Mut); -} - -public function NotifyLogin(Controller C) -{ - ZS.NotifyLogin(C); - - Super.NotifyLogin(C); -} - -public function NotifyLogout(Controller C) -{ - ZS.NotifyLogout(C); - - Super.NotifyLogout(C); -} - -defaultproperties -{ - -} \ No newline at end of file +class ZedSpawnerMut extends Mut; // backward compatibility