first version

This commit is contained in:
GenZmeY 2022-09-19 06:01:26 +03:00
parent d712dc1c74
commit bea6510710
17 changed files with 444 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.psd
/ignore

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "tools"]
path = tools
url = https://github.com/GenZmeY/KF2-BuildTools

147
DPL/Classes/DPL.uc Normal file
View File

@ -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
{
}

4
DPL/Classes/DPL.upkg Normal file
View File

@ -0,0 +1,4 @@
[Flags]
AllowDownload=False
ClientOptional=False
ServerSideOnly=True

59
DPL/Classes/DPLMut.uc Normal file
View File

@ -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
{
}

42
DPL/Classes/Lifespan.uc Normal file
View File

@ -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
{
}

20
DPL/Classes/_Logger.uc Normal file
View File

@ -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
{
}

2
DPL/Constants.uci Normal file
View File

@ -0,0 +1,2 @@
// Constants
`define NO_CONFIG 0

3
DPL/Globals.uci Normal file
View File

@ -0,0 +1,3 @@
// Imports
`include(Logger.uci)
`include(Constants.uci)

15
DPL/Logger.uci Normal file
View File

@ -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)

View File

@ -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)
[*]<Enter>.
[/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]

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

View File

@ -0,0 +1 @@
Mutators

View File

@ -0,0 +1 @@
Dropped Pickup Lifespan

View File

@ -1 +1,31 @@
# KF2-DroppedPickupLife # 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 <ANY_FOLDER_YOU_WANT>`
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\<USERNAME>\Documents\My Games\KillingFloor2\KFGame\Unpublished\BrewedPC\Script\`
# License
[GNU GPLv3](LICENSE)

61
builder.cfg Normal file
View File

@ -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=""

1
tools Submodule

@ -0,0 +1 @@
Subproject commit 0e821f3dbbc6b3528f2028b0060d3b6f7f1c4b93