diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80643f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.psd +/ignore \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..27ed978 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tools"] + path = tools + url = https://github.com/GenZmeY/KF2-BuildTools diff --git a/DPL/Classes/DPL.uc b/DPL/Classes/DPL.uc new file mode 100644 index 0000000..cd3e0c5 --- /dev/null +++ b/DPL/Classes/DPL.uc @@ -0,0 +1,147 @@ +class DPL extends Info + config(DPL); + +const LatestVersion = 1; + +const CfgLifespan = class'Lifespan'; + +enum E_PickupType +{ + PT_NotPickup, + PT_Weapon, + PT_Dosh +}; + +var private config int Version; +var private config E_LogLevel LogLevel; + +public simulated function bool SafeDestroy() +{ + `Log_Trace(); + + return (bPendingDelete || bDeleteMe || Destroy()); +} + +public event PreBeginPlay() +{ + `Log_Trace(); + + if (WorldInfo.NetMode == NM_Client) + { + `Log_Fatal("NetMode:" @ WorldInfo.NetMode); + SafeDestroy(); + return; + } + + Super.PreBeginPlay(); + + Init(); +} + +private function Init() +{ + `Log_Trace(); + + if (Version == `NO_CONFIG) + { + LogLevel = LL_Info; + SaveConfig(); + } + + CfgLifespan.static.InitConfig(Version, LatestVersion, LogLevel); + + switch (Version) + { + case `NO_CONFIG: + `Log_Info("Config created"); + + case MaxInt: + `Log_Info("Config updated to version" @ LatestVersion); + break; + + case LatestVersion: + `Log_Info("Config is up-to-date"); + break; + + default: + `Log_Warn("The config version is higher than the current version (are you using an old mutator?)"); + `Log_Warn("Config version is" @ Version @ "but current version is" @ LatestVersion); + `Log_Warn("The config version will be changed to" @ LatestVersion); + break; + } + + if (LatestVersion != Version) + { + Version = LatestVersion; + SaveConfig(); + } + + if (LogLevel == LL_WrongLevel) + { + LogLevel = LL_Info; + `Log_Warn("Wrong 'LogLevel', return to default value"); + SaveConfig(); + } + `Log_Base("LogLevel:" @ LogLevel); + + CfgLifespan.static.Load(LogLevel); + + `Log_Info("Initialized"); +} + +public function ModifyLifespan(Actor A) +{ + `Log_Trace(); + + switch (PickupType(A)) + { + case PT_Dosh: + if (CfgLifespan.default.Dosh > 0) + { + `Log_Debug("Modify dosh lifespan:" @ int(A.Lifespan) @ "->" @ CfgLifespan.default.Dosh); + A.Lifespan = float(CfgLifespan.default.Dosh); + } + else + { + `Log_Debug("Skip modify dosh lifespan"); + } + break; + + case PT_Weapon: + if (CfgLifespan.default.Weap > 0) + { + `Log_Debug("Modify weapon lifespan:" @ int(A.Lifespan) @ "->" @ CfgLifespan.default.Weap); + A.Lifespan = float(CfgLifespan.default.Weap); + } + else + { + `Log_Debug("Skip modify weapon lifespan"); + } + break; + + case PT_NotPickup: + default: + break; + } +} + +private function E_PickupType PickupType(Actor A) +{ + `Log_Trace(); + + if (KFDroppedPickup_Cash(A) != None) + { + return PT_Dosh; + } + else if (KFDroppedPickup(A) != None) + { + return PT_Weapon; + } + + return PT_NotPickup; +} + +defaultproperties +{ + +} diff --git a/DPL/Classes/DPL.upkg b/DPL/Classes/DPL.upkg new file mode 100644 index 0000000..7d148dd --- /dev/null +++ b/DPL/Classes/DPL.upkg @@ -0,0 +1,4 @@ +[Flags] +AllowDownload=False +ClientOptional=False +ServerSideOnly=True diff --git a/DPL/Classes/DPLMut.uc b/DPL/Classes/DPLMut.uc new file mode 100644 index 0000000..5b0b5cb --- /dev/null +++ b/DPL/Classes/DPLMut.uc @@ -0,0 +1,59 @@ +class DPLMut extends KFMutator; + +var private DPL DPL; + +public simulated function bool SafeDestroy() +{ + return (bPendingDelete || bDeleteMe || Destroy()); +} + +public event PreBeginPlay() +{ + Super.PreBeginPlay(); + + if (WorldInfo.NetMode == NM_Client) return; + + foreach WorldInfo.DynamicActors(class'DPL', DPL) + { + break; + } + + if (DPL == None) + { + DPL = WorldInfo.Spawn(class'DPL'); + } + + if (DPL == None) + { + `Log_Base("FATAL: Can't Spawn 'DPL'"); + SafeDestroy(); + } +} + +public function AddMutator(Mutator Mut) +{ + if (Mut == Self) return; + + if (Mut.Class == Class) + Mut.Destroy(); + else + Super.AddMutator(Mut); +} + +public function bool CheckRelevance(Actor A) +{ + local bool Relevance; + + Relevance = Super.CheckRelevance(A); + if (Relevance) + { + DPL.ModifyLifespan(A); + } + + return Relevance; +} + +defaultproperties +{ + +} diff --git a/DPL/Classes/Lifespan.uc b/DPL/Classes/Lifespan.uc new file mode 100644 index 0000000..0e0d7bc --- /dev/null +++ b/DPL/Classes/Lifespan.uc @@ -0,0 +1,42 @@ +class Lifespan extends Object + config(DPL) + abstract; + +var public config int Weap; +var public config int Dosh; + +public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel) +{ + `Log_TraceStatic(); + + switch (Version) + { + case `NO_CONFIG: + ApplyDefault(LogLevel); + + default: break; + } + + if (LatestVersion != Version) + { + StaticSaveConfig(); + } +} + +public static function Load(E_LogLevel LogLevel) +{ + `Log_TraceStatic(); +} + +protected static function ApplyDefault(E_LogLevel LogLevel) +{ + `Log_TraceStatic(); + + default.Weap = int(class'KFDroppedPickup'.default.Lifespan); + default.Dosh = int(class'KFDroppedPickup_Cash'.default.Lifespan); +} + +defaultproperties +{ + +} diff --git a/DPL/Classes/_Logger.uc b/DPL/Classes/_Logger.uc new file mode 100644 index 0000000..93fc28a --- /dev/null +++ b/DPL/Classes/_Logger.uc @@ -0,0 +1,20 @@ +class _Logger extends Object + abstract; + +enum E_LogLevel +{ + LL_WrongLevel, + LL_None, + LL_Fatal, + LL_Error, + LL_Warning, + LL_Info, + LL_Debug, + LL_Trace, + LL_All +}; + +defaultproperties +{ + +} diff --git a/DPL/Constants.uci b/DPL/Constants.uci new file mode 100644 index 0000000..1003f19 --- /dev/null +++ b/DPL/Constants.uci @@ -0,0 +1,2 @@ +// Constants +`define NO_CONFIG 0 diff --git a/DPL/Globals.uci b/DPL/Globals.uci new file mode 100644 index 0000000..a48ac52 --- /dev/null +++ b/DPL/Globals.uci @@ -0,0 +1,3 @@ +// Imports +`include(Logger.uci) +`include(Constants.uci) diff --git a/DPL/Logger.uci b/DPL/Logger.uci new file mode 100644 index 0000000..c9e710a --- /dev/null +++ b/DPL/Logger.uci @@ -0,0 +1,15 @@ +// Logger +`define Log_Tag 'DPL' + +`define LocationStatic "`{ClassName}::" $ GetFuncName() + +`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag) + +`define Log_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag) +`define Log_Error(msg) `log("ERROR:" @ `msg, (LogLevel >= LL_Error), `Log_Tag) +`define Log_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag) +`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `Log_Tag) +`define Log_Debug(msg) `log("DEBUG:" @ `msg, (LogLevel >= LL_Debug), `Log_Tag) + +`define Log_Trace(msg) `log("TRACE:" @ `Location `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag) +`define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag) diff --git a/PublicationContent/description.txt b/PublicationContent/description.txt new file mode 100644 index 0000000..88141ed --- /dev/null +++ b/PublicationContent/description.txt @@ -0,0 +1,52 @@ +[img]https://img.shields.io/static/v1?logo=GitHub&labelColor=gray&color=blue&logoColor=white&label=&message=Open Source[/img] [img]https://img.shields.io/github/license/GenZmeY/KF2-DroppedPickupLifespan[/img] [img]https://img.shields.io/steam/downloads/2864944858[/img] [img]https://img.shields.io/steam/favorites/2864944858[/img] [img]https://img.shields.io/steam/update-date/2864944858[/img] [url=https://steamcommunity.com/sharedfiles/filedetails/changelog/2864944858][img]https://img.shields.io/github/v/tag/GenZmeY/KF2-DroppedPickupLifespan[/img][/url] + +[h1]Description[/h1] +Small server-side mutator that changes the lifespan of thrown weapons and dosh. + +[h1]Whitelisted?[/h1] +No. This mod is not whitelisted and will de-rank your server. Any XP gained will not be saved. + +[h1]Usage (single player)[/h1] +[olist] +[*]Subscribe to this mutator; +[*]Start KF2; +[*]Open console (`) and input: +[b]open KF-BioticsLab?Mutator=DPL.DPLMut[/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] +[olist] +[*]Open your [b]PCServer-KFEngine.ini[/b] / [b]LinuxServer-KFEngine.ini[/b]; +[*]Find the [b][IpDrv.TcpNetDriver][/b] section and make sure that there is a line (add if not): +[b]DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload[/b] +❗️ If there are several [b]DownloadManagers=[/b] then the line above should be the first ❗️ +[*]Add the following string to the [b][OnlineSubsystemSteamworks.KFWorkshopSteamworks][/b] section (create one if it doesn't exist): +[b]ServerSubscribedWorkshopItems=2864944858[/b] +[*]Start the server and wait while the mutator is downloading; +[*]Add mutator to server start parameters: [b]?Mutator=DPL.DPLMut[/b] and restart the server. +[/olist] + +[h1]Setup (KFDPL.ini)[/h1] +Config will be created at the first start[b]*[/b]. +[list] +[*][b]Weap[/b] - time in seconds after which weapon disappears. If zero or less the default value is used. +[*][b]Dosh[/b] - time in seconds after which dosh disappears. If zero or less the default value is used. +[/list] + +Do not use too large values because a large number of objects on the map can cause lags. + +[h1]Notes[/h1] +📌 Unfortunately there is no way to change ammo lifespan for technical reasons (the CheckRelevance() function is never called on Projectile objects). Ammo will disappear within a minute. + +[h1]Troubleshooting[/h1] +[b](*)[/b] If your config is not created for some reason, create it manually with the following content: +[b][DPL.DPL] +Version=0 +[/b] + +Then start the server and check the file again - config content should be generated. + +[h1]Sources[/h1] +[url=https://github.com/GenZmeY/KF2-DroppedPickupLifespan]https://github.com/GenZmeY/KF2-DroppedPickupLifespan[/url] [b](GNU GPLv3)[/b] \ No newline at end of file diff --git a/PublicationContent/preview.png b/PublicationContent/preview.png new file mode 100644 index 0000000..cf9daa7 Binary files /dev/null and b/PublicationContent/preview.png differ diff --git a/PublicationContent/tags.txt b/PublicationContent/tags.txt new file mode 100644 index 0000000..bcf8fe8 --- /dev/null +++ b/PublicationContent/tags.txt @@ -0,0 +1 @@ +Mutators diff --git a/PublicationContent/title.txt b/PublicationContent/title.txt new file mode 100644 index 0000000..1a63b3a --- /dev/null +++ b/PublicationContent/title.txt @@ -0,0 +1 @@ +Dropped Pickup Lifespan diff --git a/README.md b/README.md index aac63fb..da4dd77 100644 --- a/README.md +++ b/README.md @@ -1 +1,31 @@ -# KF2-DroppedPickupLife \ No newline at end of file +# Dropped Pickup Lifespan + +[![Steam Workshop](https://img.shields.io/static/v1?message=workshop&logo=steam&labelColor=gray&color=blue&logoColor=white&label=steam%20)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) +[![Steam Downloads](https://img.shields.io/steam/downloads/2864944858)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) +[![Steam Favorites](https://img.shields.io/steam/favorites/2864944858)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) +[![Steam Update Date](https://img.shields.io/steam/update-date/2864944858)](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) +[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/GenZmeY/KF2-CustomTraderInventory)](https://github.com/GenZmeY/KF2-CustomTraderInventory/tags) +[![GitHub](https://img.shields.io/github/license/GenZmeY/KF2-CustomTraderInventory)](LICENSE) + +# Description +Small server-side mutator that changes the lifespan of thrown weapons and dosh. + +# Usage & Setup +[See steam workshop page](https://steamcommunity.com/sharedfiles/filedetails/?id=2864944858) + +# Build +**Note:** If you want to build/test/brew/publish a mutator without git-bash and/or scripts, follow [these instructions](https://tripwireinteractive.atlassian.net/wiki/spaces/KF2SW/pages/26247172/KF2+Code+Modding+How-to) instead of what is described here. +1. Install [Killing Floor 2](https://store.steampowered.com/app/232090/Killing_Floor_2/), Killing Floor 2 - SDK and [git for windows](https://git-scm.com/download/win); +2. open git-bash and go to any folder where you want to store sources: +`cd ` +3. Clone this repository and go to the source folder: +`git clone https://github.com/GenZmeY/KF2-CustomTraderInventory && cd KF2-CustomTraderInventory` +4. Download dependencies: +`git submodule init && git submodule update` +5. Compile: +`./tools/builder -c` +5. The compiled files will be here: +`C:\Users\\Documents\My Games\KillingFloor2\KFGame\Unpublished\BrewedPC\Script\` + +# License +[GNU GPLv3](LICENSE) diff --git a/builder.cfg b/builder.cfg new file mode 100644 index 0000000..b75f0c4 --- /dev/null +++ b/builder.cfg @@ -0,0 +1,61 @@ +### Build parameters ### + +# If True - compresses the mutator when compiling +# Scripts will be stored in binary form +# (reduces the size of the output file) +StripSource="True" + +# Mutators to be compiled +# Specify them with a space as a separator, +# Mutators will be compiled in the specified order +PackageBuildOrder="DPL" + + +### Brew parameters ### + +# Packages you want to brew using @peelz's patched KFEditor. +# Useful for cases where regular brew doesn't put *.upk inside the package. +# Specify them with a space as a separator, +# The order doesn't matter +PackagePeelzBrew="" + + +### Steam Workshop upload parameters ### + +# Mutators that will be uploaded to the workshop +# Specify them with a space as a separator, +# The order doesn't matter +PackageUpload="DPL" + + +### Test parameters ### + +# Map: +Map="KF-Nuked" + +# Game: +# Survival: KFGameContent.KFGameInfo_Survival +# WeeklyOutbreak: KFGameContent.KFGameInfo_WeeklySurvival +# Endless: KFGameContent.KFGameInfo_Endless +# Objective: KFGameContent.KFGameInfo_Objective +# Versus: KFGameContent.KFGameInfo_VersusSurvival +Game="KFGameContent.KFGameInfo_Survival" + +# Difficulty: +# Normal: 0 +# Hard: 1 +# Suicide: 2 +# Hell: 3 +Difficulty="0" + +# GameLength: +# 4 waves: 0 +# 7 waves: 1 +# 10 waves: 2 +GameLength="0" + +# Mutators +Mutators="DPL.DPL_Mut" + +# Additional parameters +Args="" diff --git a/tools b/tools new file mode 160000 index 0000000..0e821f3 --- /dev/null +++ b/tools @@ -0,0 +1 @@ +Subproject commit 0e821f3dbbc6b3528f2028b0060d3b6f7f1c4b93