Compare commits

..

49 Commits

Author SHA1 Message Date
21353a8a3d
Update README.md 2024-03-09 19:55:43 +03:00
4c6beaaed9
Update README.md 2024-02-27 22:27:43 +03:00
e9f5b8b2b8
Create LEGAL.md 2024-02-27 22:18:28 +03:00
6efe21b7a6
update ci/cd 2023-12-31 20:49:57 +03:00
98ddf593eb
Update README.md 2023-11-22 03:59:29 +03:00
8d8e65777b
Update README.md 2023-11-22 03:54:06 +03:00
b44514dfbb
Merge pull request #10 from GenZmeY/add-fhud
add FriendlyHUD to the list of compatible mutators
2023-11-21 01:08:47 +03:00
d76d279447
add FriendlyHUD to the list of compatible mutators 2023-11-16 21:14:54 +03:00
bbf86d6dcc
update steam description 2023-10-09 18:23:59 +03:00
e05982622c
add AmmoMulti and WorkshopTool to compatible list 2023-10-09 18:21:37 +03:00
ed66f2bbc8
add True Random Boss 2023-10-07 23:50:19 +03:00
90beee7933
update megalinter ci/cd 2023-10-07 23:45:38 +03:00
ef16481633
Update README.md 2023-09-19 23:15:30 +03:00
affffe4690
Update README.md 2023-09-14 23:12:58 +03:00
416eebbdfc
Update README.md 2023-09-11 04:53:22 +03:00
d3827c9e5a
add a delay before checking ranked status 2023-09-11 03:32:30 +03:00
330322dfa0
add UKFP compatibility (again) 2023-09-10 04:24:12 +03:00
256f3df4e8
Merge pull request #6 from GenZmeY/group-names
add mutator group name
2023-06-29 00:56:20 +03:00
2a3a56043e
Merge pull request #7 from GenZmeY/readme-startwave
add StartWave to compatible list
2023-06-29 00:56:02 +03:00
d976e94696 add GC before server travel 2023-06-28 01:06:21 +03:00
2f035c60bd add StartWave to compatible list 2023-05-21 01:55:24 +03:00
cb8140f705 add mutator group name 2023-05-14 05:12:21 +03:00
2293ce47e8 add badges 2023-05-14 05:09:44 +03:00
83ef34bf34
Merge pull request #4 from GenZmeY/MegaLinter
Mega linter
2023-05-14 04:52:20 +03:00
cfa8257071 update .editorconfig 2023-05-14 04:46:11 +03:00
42c844fffd update style 2023-05-14 04:41:54 +03:00
64893b7484 add MegaLinter 2023-05-14 04:32:45 +03:00
0a5e62e3e7 add .editorconfig 2023-05-14 04:32:25 +03:00
98194b3917 update build tools 2023-05-14 04:20:07 +03:00
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
6305c8f162 UnofficialKFPatch compat 2022-11-26 03:02:02 +03:00
e8d229e5b7
Update README.md 2022-11-22 17:50:33 +03:00
970d0f13b2
Update README.md 2022-11-22 17:48:11 +03:00
0c649b444e
Update DEV.md 2022-11-02 13:27:19 +03:00
b8bc4a58eb
Update README.md 2022-10-31 19:41:28 +03:00
f6eeda01eb
Update DEV.md 2022-10-30 05:24:28 +03:00
970335943a prepare for publication 2022-10-30 04:56:22 +03:00
6713766a64 update description 2022-09-15 16:39:32 +03:00
18 changed files with 988 additions and 538 deletions

33
.editorconfig Normal file
View File

@ -0,0 +1,33 @@
root = true
# Global
[*]
indent_style = unset
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = unset
# Unreal Engine 3 / Source
[*.uc]
indent_style = tab
[*.{uci,upkg}]
# Unreal Engine 3 / i18n
[*.{chn,cht,cze,dan,deu,dut,esl,esn,fra,frc,hun,int,ita,jpn,kor,pol,por,ptb,rus,tur,ukr}]
charset = utf-16le
# Other
[*.md]
indent_style = space
trim_trailing_whitespace = false
[*.yml]
indent_style = space
indent_size = 2
[*.{txt,cfg,conf}]
indent_style = tab

114
.github/workflows/mega-linter.yml vendored Normal file
View File

@ -0,0 +1,114 @@
---
name: MegaLinter
permissions: read-all
on:
push:
pull_request:
branches:
- master
env:
APPLY_FIXES: none
APPLY_FIXES_EVENT: pull_request
APPLY_FIXES_MODE: commit
FILTER_REGEX_EXCLUDE: (mega-linter.yml)
DISABLE: SPELL
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: MegaLinter
uses: oxsecurity/megalinter@7e042c726c68415475b05a65a686c612120a1232
id: ml
env:
VALIDATE_ALL_CODEBASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive production artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
if: success() || failure()
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
- name: Set APPLY_FIXES_IF var
run: |
printf 'APPLY_FIXES_IF=%s\n' "${{
steps.ml.outputs.has_updated_sources == 1 &&
(
env.APPLY_FIXES_EVENT == 'all' ||
env.APPLY_FIXES_EVENT == github.event_name
) &&
(
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.repository
)
}}" >> "${GITHUB_ENV}"
- name: Set APPLY_FIXES_IF_* vars
run: |
printf 'APPLY_FIXES_IF_PR=%s\n' "${{
env.APPLY_FIXES_IF == 'true' &&
env.APPLY_FIXES_MODE == 'pull_request'
}}" >> "${GITHUB_ENV}"
printf 'APPLY_FIXES_IF_COMMIT=%s\n' "${{
env.APPLY_FIXES_IF == 'true' &&
env.APPLY_FIXES_MODE == 'commit' &&
(!contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref))
}}" >> "${GITHUB_ENV}"
- name: Create Pull Request with applied fixes
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
id: cpr
if: env.APPLY_FIXES_IF_PR == 'true'
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot
- name: Create PR output
if: env.APPLY_FIXES_IF_PR == 'true'
run: |
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: Prepare commit
if: env.APPLY_FIXES_IF_COMMIT == 'true'
run: sudo chown -Rc $UID .git/
- name: Commit and push applied linter fixes
uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d
if: env.APPLY_FIXES_IF_COMMIT == 'true'
with:
branch: >-
${{
github.event.pull_request.head.ref ||
github.head_ref ||
github.ref
}}
commit_message: "[MegaLinter] Apply linters fixes"
commit_user_name: "github-actions"
commit_user_email: "github-actions[bot]@users.noreply.github.com"

161
DEV.md Normal file
View File

@ -0,0 +1,161 @@
# [SML] Developer Guide
**SML compatible mutator development guide**
## Mutator template
You can use this template to make the mutator compatible with SML.
Here I will use `Example` as mutator name. **Replace it with yours.**
**ExampleMut.uc**
```unrealscript
class ExampleMut extends KFMutator;
var private Example Example;
public simulated function bool SafeDestroy()
{
return (bPendingDelete || bDeleteMe || Destroy());
}
public event PreBeginPlay()
{
Super.PreBeginPlay();
if (WorldInfo.NetMode == NM_Client) return;
foreach WorldInfo.DynamicActors(class'Example', Example)
{
break;
}
if (Example == None)
{
Example = WorldInfo.Spawn(class'Example');
}
if (Example == None)
{
`Log("Example: FATAL: Can't Spawn 'Example'");
SafeDestroy();
}
}
public function AddMutator(Mutator Mut)
{
if (Mut == Self) return;
if (Mut.Class == Class)
ExampleMut(Mut).SafeDestroy();
else
Super.AddMutator(Mut);
}
public function NotifyLogin(Controller C)
{
Example.NotifyLogin(C);
Super.NotifyLogin(C);
}
public function NotifyLogout(Controller C)
{
Example.NotifyLogout(C);
Super.NotifyLogout(C);
}
static function String GetLocalString(optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2)
{
return String(class'Example');
}
defaultproperties
{
}
```
**Example.uc**
```unrealscript
class Example extends Info;
public event PreBeginPlay()
{
Super.PreBeginPlay();
// do some initialization here
}
public event PostBeginPlay()
{
Super.PostBeginPlay();
// do some initialization here
}
public function NotifyLogin(Controller C)
{
// Do what you need here when the player log in
}
public function NotifyLogout(Controller C)
{
// Do what you need here when the player log out
}
public simulated function vector GetTargetLocation(optional actor RequestedBy, optional bool bRequestAlternateLoc)
{
local Controller C;
C = Controller(RequestedBy);
if (C != None) { bRequestAlternateLoc ? NotifyLogout(C) : NotifyLogin(C); }
return Super.GetTargetLocation(RequestedBy, bRequestAlternateLoc);
}
defaultproperties
{
}
```
That's all. You can create new classes and add any code to `Example.uc` (yay!), but refrain from implementing anything else in `ExampleMut.uc` because it will not be used.
## Limitations
❌ Can't make ranked game mode this way;
❌ SML can only emulate [`NotifyLogin(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/Engine/Classes/Mutator.uc#L147) and [`NotifyLogout(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/Engine/Classes/Mutator.uc#L141), other functions of the [`Mutator`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/master/Engine/Classes/Mutator.uc) and [`KFMutator`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/master/KFGame/Classes/KFMutator.uc) classes are not supported - look for workarounds in this case.
## Tips
## 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:
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
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.
Therefore, if you want to gain experience - make sure that [`ValidateForXP(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/KFGame/Classes/KFGameInfo.uc#L2564) does not receive custom zed classes or custom damage types.
For example you can change your custom weapon to use only default damage types or try changing the `DamageHistory` and/or `MonsterClass` before it gets into [`DistributeMoneyAndXP(...)`](https://github.com/GenZmeY/KF2-Dev-Scripts/blob/23d1ca3a9a2f62692741e77039f03fe0a913be1d/KFGame/Classes/KFGameInfo.uc#L2489).
### Replacing base classes to bypass restrictions
In some cases, changing the base classes of the game can help. For example, we cannot make [TAWOD](https://steamcommunity.com/sharedfiles/filedetails/?id=2379769040) and SML compatible because the [PreventDeath(...)](https://github.com/GenZmeY/KF2-TAWOD/blob/master/TAWOD/Classes/TAWODMut.uc#L19) function is not supported. But this can be bypassed by replacing the player's Pawn base class with custom Pawn class:
```unrealscript
WorldInfo.Game.DefaultPawnClass = class'ExamplePawn_Human'; // Put this to `PostBeginPlay()` of your Example.uc
```
And now we can implement all weapons drop in `ExamplePawn_Human.uc` (create one):
```unrealscript
class ExamplePawn_Human extends KFPawn_Human;
public function ThrowWeaponOnDeath()
{
local KFWeapon KFW;
if (InvManager == None) return;
foreach InvManager.InventoryActors(class'KFWeapon', KFW)
if (KFW.bDropOnDeath && KFW.CanThrow())
KFP.TossInventory(KFW);
}
```
***
**Good luck and happy modding! 🙃**

66
LEGAL.md Normal file
View File

@ -0,0 +1,66 @@
# SafeMutLoader (SML) is legal and does not violate the [KF2 EULA](https://store.steampowered.com/eula/232090_eula_0).
## Here's why in detail:
Let's look at the [EULA](https://store.steampowered.com/eula/232090_eula_0) points that relate to modifications:
> ### 2. Permitted User Modifications and New Creations
> Some of our games come with a KILLING FLOOR 2 editor. You can use editors to make mods or create new content to be played in KILLING FLOOR 2. You agree that you will not distribute or share the KILLING FLOOR 2 editor because it is not shareware. You agree that any new creations or materials that you make for KILLING FLOOR 2, with or without the KILLING FLOOR 2 editor, (collectively referred to as “Mods”) are subject to the following restrictions:
> Your Mods must only work with the full, registered copy of KILLING FLOOR 2, not independently or with any other software.
SML only works with a full registered copy of KILLING FLOOR 2 and is not intended to work with any other software.
> Your Mods must not contain modifications to any executable file(s).
SML does not modify KILLING FLOOR 2 executables.
> Your Mods must not contain any sexually explicit, harmful, threatening, abusive, defamatory, obscene, hateful, racially or ethnically offensive imagery or libelous, defamatory, or other illegal material, material that is scandalous or invades the rights of privacy or publicity of any third party.
SML does not contain anything listed here.
> Your Mods must not contain, or be used in conjunction with, any trademarks, copyright protected work, or other recognizable property of third parties without their written authority.
SML does not contain any trademarks or property of third parties.
> Your Mods must not be used by you, or anyone else, for any commercial exploitation including, but not limited to in-game advertising, other advertising or marketing for any company, product or service.
SML does not have any functionality for commercial use or advertising, SML is distributed free of charge.
> While we encourage folks to make Mods, Mods will not be supported by Tripwire Interactive and its licensors, licensees or suppliers, and if distributed pursuant to this license your Mods must include a statement to that effect.
SML is supported by its author. SML is distributed under the GNU GPLv3 license, which states that this program is provided "as is" and without any warranties.
> Your Mods must be distributed for free, period. Neither you, nor any other person or party, may sell them to anyone, commercially exploit them in any way, or charge anyone for receiving or using them without prior written consent from Tripwire Interactive. You may exchange them at no charge among other end users and distribute them to others over the Internet, on magazine cover disks, or otherwise for free.
SML is distributed free of charge, including both compiled mod files and its source code.
> The prohibitions and restrictions in this section apply to anyone in possession of KILLING FLOOR 2 or any Mods.
Of course.
> ### 3. Commercial Exploitation
> You may not use KILLING FLOOR 2, or any Mods created for or from KILLING FLOOR 2 or using the KILLING FLOOR 2 editor or any other tools provided with this KILLING FLOOR 2, for any commercial purposes without the prior written consent of Tripwire Interactive or its authorized licensees including, but not limited to, the following rules: 1. If you are the proprietor of an Internet café or gaming room, you may operate the KILLING FLOOR 2 in a “pay for play” environment provided that all computers used have validly licensed KILLING FLOOR 2 installed, such KILLING FLOOR 2 having been properly purchased through one of our licensees. 2. You may not, without prior written consent from Tripwire Interactive, operate KILLING FLOOR 2 in any gaming contest where (a) the cash value of all winnings and prizes paid throughout the entire competition is equal to or greater than US$10,000.00 or (b) the name of the event, or any individual contest therein, incorporates or approximates the name of a company, product or commercial service or (c) any company has provided, whether donated or as sponsorship any prizes, products or services worth with a fair market value of over US $20,000.00.
SML is distributed free of charge, including both compiled mod files and its source code.
> ### 4. Restrictions on Use
> Just to make sure you understand what you can and cannot do with KILLING FLOOR 2, here is a list of restrictions to your use of KILLING FLOOR 2 under this EULA:
> You may not decompile, modify, reverse engineer, publicly display, prepare derivative works based on KILLING FLOOR 2 (except as permitted in Section 2, above), disassemble or otherwise reproduce KILLING FLOOR 2.
SML is not a derivative work. No decompilation of game files was used during the development of SML. SML works only on the functionality provided by KILLING FLOOR 2 and Unreal Script available through the KILLING FLOOR 2 - SDK.
> Except as set forth herein, you may not rent, sell, lease, barter, sublicense or distribute KILLING FLOOR 2. You may not delete the copyright notices or any other proprietary legends on the original copy of KILLING FLOOR 2.
SML cannot be used for the purposes listed here. SML does not affect copyright notices in KILLING FLOOR 2.
> You may not offer KILLING FLOOR 2 on a pay per play basis or otherwise commercially exploit KILLING FLOOR 2 or use KILLING FLOOR 2 for any commercial purpose except as described in this agreement.
SML cannot be used for the purposes listed here.
> You may not electronically transmit KILLING FLOOR 2 from one computer to another or over a network except as described in this agreement..
SML cannot be used for these purposes listed here.

View File

@ -1,41 +1,23 @@
[h1][b]Use non-whitelisted mutators and stay ranked[/b][/h1] [h1][b]Use non-whitelisted mutators and stay ranked[/b][/h1]
[h1]Limitations[/h1] [h1]Usage (server only)[/h1]
⚠️ SML only has an effect when compatible mutators are used. If you use incompatible mutators you will lose ranked status. [olist]
⚠️ SML incompatible with [b][url=https://github.com/th3-z/kf2-acpp]AccessPlus[/url][/b]. If you need something from there, implement it as an SML compatible mutator using [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2863210737]developer guide[/url]. [*]Subscribe your server to this.
[*]Add [b]SML.Mut[/b] [u]first[/u] to your list of mutators, example:
[code]
?Mutator=SML.Mut,UnofficialKFPatch.UKFPMutator,AAL.AALMut,DiscordMessage.DMMutator,YAS.YASMut,CTI.CTIMut,CVC.CVCMut,ZedSpawner.ZedSpawnerMut
[/code]
(add/remove [b]compatible[/b] mutators you need)
[/olist]
⚠️ Doesn't work in single player
⚠️ SML must be first in the mutators list or it won't work.
⚠️ SML only has an effect when [b]compatible[/b] mutators are used (the list below). If you use incompatible mutators you will lose ranked status.
⚠️ SML is a server-side mutator, clients never download it. Therefore, no one will know about you using SML if you dont tell yourself (or if you share with the whole world the BrewedPC folder where you put the SML, lol).
⚠️ SML is incompatible with [url=https://github.com/th3-z/kf2-acpp]AccessPlus[/url] and other mods based on it. If you need something from there, implement it as an SML compatible mutator using [url=https://github.com/GenZmeY/KF2-SafeMutLoader/blob/master/DEV.md]developer guide[/url].
[h1]Compatible mutators[/h1] [h1]Compatible mutators[/h1]
🟢 Any whitelisted mutators https://github.com/GenZmeY/KF2-SafeMutLoader#compatible-mutators
🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2848836389]Admin Auto Login[/url]
🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899]Controlled Vote Collector[/url]
🟡 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2830826239]Custom Trader Inventory[/url]
[list]
[*]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 [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]
🟡 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2811290931]Zed Spawner[/url]
[list]
[*]Since [url=https://wiki.killingfloor2.com/index.php?title=Update_1133_(Killing_Floor_2)]KF2 v1133[/url] zed preload causes the server to unrank for some reason (current version of ZedSpawner does not allow you to disable preload, but I will add it later).
[/list]
🟢 [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2521826524]Yet Another Scoreboard[/url]
[h1]Developer guide[/h1]
If you want to make your mutator compatible with SML use this:
[url=https://steamcommunity.com/sharedfiles/filedetails/?id=2863210737]Developer Guide[/url]
If you make a public mutator with SML support, I'd be happy if you tell me about it so I can add it to the list above.
[h1]Usage[/h1]
[code]
?Mutator=SML.Mut,AAL.AALMut,YAS.YASMut,CTI.CTIMut,CVC.CVCMut,ZedSpawner.ZedSpawnerMut
[/code]
(replace the map and add/remove [b]compatible[/b] mutators you need)
❗️ SML must be first in the mutators list or it won't work.
❗️ SML is a server-side mutator, clients never download it. Therefore, no one will know about SML if you dont tell yourself. You can also accidentally give it to the whole world if you use a redirect and share the folder where it's located. Be careful about this.
❗️ I also really hope you don't report this to TWI. If I find this blocked, I will probably be upset in the world and in the people with whom I shared this :(
[h1]Sources[/h1] [h1]Sources[/h1]
Right now, I don't want to post SML sources because I'm planning to submit several whitelist requests for my mutators. TWI will probably look at my github (At least I hope so) and I don't want them to see SML. [url=https://github.com/GenZmeY/KF2-SafeMutLoader]https://github.com/GenZmeY/KF2-SafeMutLoader[/url] [b](GNU GPLv3)[/b]
But later I will post it under the GNU GPLv3.

View File

@ -1,176 +0,0 @@
[SML] Developer Guide
[b]SML compatible mutator development guide[/b]
Mutator template
You can use this template to make the mutator compatible with [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2863226847]SML[/url].
Here I will use "[b]Example[/b]" as mutator name. Replace it with yours.
[b]ExampleMut.uc[/b]
[code]
class ExampleMut extends KFMutator;
var private Example Example;
public simulated function bool SafeDestroy()
{
return (bPendingDelete || bDeleteMe || Destroy());
}
public event PreBeginPlay()
{
Super.PreBeginPlay();
if (WorldInfo.NetMode == NM_Client) return;
foreach WorldInfo.DynamicActors(class'Example', Example)
{
break;
}
if (Example == None)
{
Example = WorldInfo.Spawn(class'Example');
}
if (Example == None)
{
`Log("Example: FATAL: Can't Spawn 'Example'");
SafeDestroy();
}
}
public function AddMutator(Mutator Mut)
{
if (Mut == Self) return;
if (Mut.Class == Class)
Mut.Destroy();
else
Super.AddMutator(Mut);
}
public function NotifyLogin(Controller C)
{
Example.NotifyLogin(C);
Super.NotifyLogin(C);
}
public function NotifyLogout(Controller C)
{
Example.NotifyLogout(C);
Super.NotifyLogout(C);
}
static function String GetLocalString(optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2)
{
return String(class'Example');
}
defaultproperties
{
}
[/code]
[b]Example.uc[/b]
[code]
class Example extends Info;
public event PreBeginPlay()
{
Super.PreBeginPlay();
// do some initialization here
}
public event PostBeginPlay()
{
Super.PostBeginPlay();
// do some initialization here
}
public function NotifyLogin(Controller C)
{
// Do what you need here when the player log in
}
public function NotifyLogout(Controller C)
{
// Do what you need here when the player log out
}
public simulated function vector GetTargetLocation(optional actor RequestedBy, optional bool bRequestAlternateLoc)
{
local Controller C;
C = Controller(RequestedBy);
if (C != None) { bRequestAlternateLoc ? NotifyLogout(C) : NotifyLogin(C); }
return Super.GetTargetLocation(RequestedBy, bRequestAlternateLoc);
}
defaultproperties
{
}
[/code]
That's all. You can create new classes and add any code to [b]Example.uc[/b], but refrain from implementing anything else in [b]ExampleMut.uc[/b]
Limitations
❌ Can't make ranked game mode this way;
❌ [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2863226847]SML[/url] can only emulate [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/9553ac0b31c729c27e9cd0a460ab5a7bae2fd799/Engine/Classes/Mutator.uc#L147]NotifyLogin(...)[/url] and [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/9553ac0b31c729c27e9cd0a460ab5a7bae2fd799/Engine/Classes/Mutator.uc#L141]NotifyLogout(...)[/url], other functions of the [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/9553ac0b31c729c27e9cd0a460ab5a7bae2fd799/Engine/Classes/Mutator.uc]Mutator[/url] and [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/9553ac0b31c729c27e9cd0a460ab5a7bae2fd799/Engine/Classes/KFMutator.uc]KFMutator[/url] classes are not supported - look for workarounds in this case.
[Tips] Alternative to the InitMutator(...) function
Even though the [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/9553ac0b31c729c27e9cd0a460ab5a7bae2fd799/KFGame/Classes/KFMutator.uc#L22]InitMutator(...)[/url] function is not supported, you can still parse the startup string if you need to:
Refer to [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/9553ac0b31c729c27e9cd0a460ab5a7bae2fd799/Engine/Classes/GameInfo.uc#L209]WorldInfo.Game.ServerOptions[/url] or [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/9553ac0b31c729c27e9cd0a460ab5a7bae2fd799/Engine/Classes/WorldInfo.uc#L1315]WorldInfo.GetLocalURL()[/url] and get the option from there. It's best to do this in [b]PreBeginPlay()[/b] or [b]PostBeginPlay()[/b] of your [b]Example.uc[/b] (as well as other initializations).
[Tips] XP for custom Zeds / Weapons
While custom weapons and zeds won't make your server unranked, the [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/513c60070e2b700b5c311843754ed0e39b55a14e/KFGame/Classes/KFGameInfo.uc#L2594]ValidateForXP(...)[/url] function will not allow you to gain experience if it detects a custom zed or custom damage type.
To work around this, don't use custom damage types on custom weapons, or replace information in [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/513c60070e2b700b5c311843754ed0e39b55a14e/KFGame/Classes/KFPawn.uc#L182]DamageHistory[/url] before it gets into the [url=https://github.com/GenZmeY/KF2-Dev-Scripts/blob/513c60070e2b700b5c311843754ed0e39b55a14e/KFGame/Classes/KFGameInfo.uc#L2489]DistributeMoneyAndXP(...)[/url] function.
[Tips] Replacing base classes to bypass restrictions
In some cases, changing the base classes of the game can help. For example, we cannot make [b][url=https://steamcommunity.com/sharedfiles/filedetails/?id=2379769040]TAWOD[/url][/b] and [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2863226847]SML[/url] compatible because the [url=https://github.com/GenZmeY/KF2-TAWOD/blob/master/TAWOD/Classes/TAWODMut.uc#L19]PreventDeath(...)[/url] function is not supported. But this can be bypassed by replacing the player's Pawn base class with custom Pawn class:
[code]
WorldInfo.Game.DefaultPawnClass = class'ExamplePawn_Human';
[/code]
(This can be done in [b]PostBeginPlay()[/b])
And now we can implement all weapons drop in [b]ExamplePawn_Human.uc[/b]:
[code]
class TAWODPawn_Human extends KFPawn_Human;
public function ThrowActiveWeapon(optional bool bDestroyWeap)
{
local KFWeapon KFW;
if (Role < ROLE_Authority)
{
return;
}
if (Health <= 0)
{
if (InvManager != None)
foreach KFP.InvManager.InventoryActors(class'KFWeapon', KFW)
if (KFW != None && KFW.bDropOnDeath && KFW.CanThrow())
KFP.TossInventory(KFW);
}
else
{
super.ThrowActiveWeapon(bDestroyWeap);
}
}
[/code]
[Tips] Cloning DLC weapons
🛠[b] <UNDER_CONSTRUCTION> [/b]🛠

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 KiB

View File

@ -1,25 +1,57 @@
# KF2-SafeMutLoader # KF2-SafeMutLoader
[![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=2863226847) [![Downloads](https://img.shields.io/github/downloads/GenZmeY/KF2-SafeMutLoader/total)](https://github.com/GenZmeY/KF2-SafeMutLoader/releases)
[![Steam Downloads](https://img.shields.io/steam/downloads/2863226847)](https://steamcommunity.com/sharedfiles/filedetails/?id=2863226847) [![MegaLinter](https://github.com/GenZmeY/KF2-SafeMutLoader/actions/workflows/mega-linter.yml/badge.svg?branch=master)](https://github.com/GenZmeY/KF2-SafeMutLoader/actions/workflows/mega-linter.yml)
[![Steam Favorites](https://img.shields.io/steam/favorites/2863226847)](https://steamcommunity.com/sharedfiles/filedetails/?id=2863226847) [![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/GenZmeY/KF2-SafeMutLoader)](https://github.com/GenZmeY/KF2-SafeMutLoader/releases)
[![Steam Update Date](https://img.shields.io/steam/update-date/2863226847)](https://steamcommunity.com/sharedfiles/filedetails/?id=2863226847)
[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/GenZmeY/KF2-SafeMutLoader)](https://github.com/GenZmeY/KF2-SafeMutLoader/tags)
[![GitHub](https://img.shields.io/github/license/GenZmeY/KF2-SafeMutLoader)](LICENSE) [![GitHub](https://img.shields.io/github/license/GenZmeY/KF2-SafeMutLoader)](LICENSE)
# Description ## Description
Use non-whitelisted mutators and stay ranked Use non-whitelisted mutators and stay ranked.
# Usage ## Legal
SafeMutLoader is legal and does not violate the [KF2 EULA](https://store.steampowered.com/eula/232090_eula_0). Here's why in detail: [LEGAL.md](LEGAL.md).
However, for some reason SML is getting banned in the steam workshop, so **use it at your own risk**.
## Usage (server only)
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`
* **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:
```text
?Mutator=SML.Mut,FriendlyHUD.FriendlyHUDMutator,YAS.Mut,CTI.Mut,CVC.Mut,AAL.Mut
``` ```
?Mutator=SML.Mut,AAL.AALMut,YAS.YASMut,CTI.CTIMut,CVC.CVCMut,ZedSpawner.ZedSpawnerMut (add/remove **compatible** mutators you need)
```
(replace the map and add/remove compatible mutators you need)
❗️ SML must be first in the mutators list or it won't work. ⚠️ Doesn't work in single player
❗️ SML is a server-side mutator, clients never download it. Therefore, no one will know about SML if you dont tell yourself. You can also accidentally give it to the whole world if you use a redirect and share the folder where it's located. Be careful about this. ⚠️ SML must be first in the mutators list or it won't work.
⚠️ SML only has an effect when **compatible** mutators are used (the list below). If you use incompatible mutators you will lose ranked status.
⚠️ SML is a server-side mutator, clients never download it. Therefore, no one will know about you using SML if you dont tell yourself (or if you share with the whole world the `BrewedPC` folder where you put the SML, lol).
⚠️ SML is incompatible with [AccessPlus](https://github.com/th3-z/kf2-acpp) and other mods based on it. If you need something from there, implement it as an SML compatible mutator using [developer guide](https://github.com/GenZmeY/KF2-SafeMutLoader/blob/master/DEV.md).
# Build ## Compatible mutators
🟢 Any whitelisted mutators
🟢 [Admin Auto Login](https://steamcommunity.com/sharedfiles/filedetails/?id=2848836389)
🟢 [AmmoMulti](https://steamcommunity.com/sharedfiles/filedetails/?id=3026449204)
🟢 [Controlled Vote Collector](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899)
🟡 [Custom Trader Inventory](https://steamcommunity.com/sharedfiles/filedetails/?id=2830826239)
Using `UnlockDLC=ReplaceFilter` will unrank the server when someone buys DLC weapons. Use `UnlockDLC=ReplaceWeapons` to get around this.
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)
🟢 [FriendlyHUD](https://steamcommunity.com/sharedfiles/filedetails/?id=1819268190)
🟢 [Looted Trader Inventory](https://steamcommunity.com/sharedfiles/filedetails/?id=2864857909)
🟡 [StartWave](https://github.com/GenZmeY/KF2-StartWave)
`mutate startwave X` command not working.
🟢 [True Random Boss](https://steamcommunity.com/sharedfiles/filedetails/?id=3047331564)
🟢 [Unofficial Killing Floor 2 Patch](https://steamcommunity.com/sharedfiles/filedetails/?id=2875147606)
🟢 [WorkshopTool](https://steamcommunity.com/sharedfiles/filedetails/?id=3047217103)
🟢 [Yet Another Scoreboard](https://steamcommunity.com/sharedfiles/filedetails/?id=2521826524)
🟡 [Zed Spawner](https://steamcommunity.com/sharedfiles/filedetails/?id=2811290931)
Since KF2 [v1133](https://wiki.killingfloor2.com/index.php?title=Update_1133_(Killing_Floor_2)) zed preload causes the server to unrank for some reason. Disable it in ZedSpawner settings (`bPreloadContentServer=False`) to stay ranked.
## Making SML-compatible mutators
See [developer guide](https://github.com/GenZmeY/KF2-SafeMutLoader/blob/master/DEV.md)
## Build & Upload
**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. **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); 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: 2. open git-bash and go to any folder where you want to store sources:
@ -28,10 +60,13 @@ Use non-whitelisted mutators and stay ranked
`git clone https://github.com/GenZmeY/KF2-SafeMutLoader && cd KF2-SafeMutLoader` `git clone https://github.com/GenZmeY/KF2-SafeMutLoader && cd KF2-SafeMutLoader`
4. Download dependencies: 4. Download dependencies:
`git submodule init && git submodule update` `git submodule init && git submodule update`
5. Compile: 5. Build and upload to steam workshop:
`./tools/builder -c` `./tools/builder -cbu`
5. The compiled files will be here: 6. Find `SafeMutLoader` in your workshop and change `Visibility` to `Unlisted` so your server can download it (don't use `Public` visibility)
`C:\Users\<USERNAME>\Documents\My Games\KillingFloor2\KFGame\Unpublished\BrewedPC\Script\`
# License ## Contributing
[GNU GPLv3](LICENSE) If you make a mod compatible with SML I'll be happy to add it to the list of compatible mutators.
Contact me in any convenient way (for example, create an [issue](https://github.com/GenZmeY/KF2-SafeMutLoader/issues))
## License
[![license](https://www.gnu.org/graphics/gplv3-with-text-136x68.png)](LICENSE)

View File

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

View File

@ -1,106 +1,143 @@
class Mut extends KFMutator; class Mut extends KFMutator;
const SML = class'SafeMutLoader'; const SML = class'SafeMutLoader';
const OptAC = "AccessControl"; const OptAC = "AccessControl";
const OptMut = "Mutator"; const OptMut = "Mutator";
var private E_LogLevel LogLevel; var private E_LogLevel LogLevel;
public function PreBeginPlay() public function PreBeginPlay()
{ {
Super.PreBeginPlay(); Super.PreBeginPlay();
LogLevel = SML.static.GetLogLevel(); LogLevel = SML.static.GetLogLevel();
`Log_Trace(); `Log_Trace();
if (CorrectLoadOrder()) if (CorrectLoadOrder())
{ {
ModifyLoad(); ModifyLoad();
} }
else else
{ {
`Log_Fatal(SML.static.GetName(Self) @ "must be loaded first."); `Log_Fatal(SML.static.GetName(Self) @ "must be loaded first.");
} }
} }
public function AddMutator(Mutator Mut) public function AddMutator(Mutator Mut)
{ {
`Log_Trace(); `Log_Trace();
if (CorrectLoadOrder() || Mut == Self) return; if (CorrectLoadOrder() || Mut == Self) return;
if (Mut.Class == Class) if (Mut.Class == Class)
Mut.Destroy(); {
else Mut.Destroy();
Super.AddMutator(Mut); }
} else
{
private function bool CorrectLoadOrder() Super.AddMutator(Mut);
{ }
`Log_Trace(); }
return ( private function bool CorrectLoadOrder()
WorldInfo.Game.BaseMutator == None || {
WorldInfo.Game.BaseMutator == Self); `Log_Trace();
}
return (
private function ModifyLoad() WorldInfo.Game.BaseMutator == None ||
{ WorldInfo.Game.BaseMutator == Self);
local String LoadURL; }
local String LoadParams;
local String MutatorsRaw; private function ModifyLoad()
local String AccessControlRaw; {
local Array<String> Mutators; local String LoadURL;
local int Index; local String LoadParams;
local String MutatorsRaw;
`Log_Trace(); local String AccessControlRaw;
local Array<String> Mutators;
LoadURL = WorldInfo.GetLocalURL(); local int PrevServerActorsCount;
LoadParams = Mid(LoadURL, InStr(LoadURL, "?")); local int Index;
MutatorsRaw = WorldInfo.Game.ParseOption(LoadParams, OptMut); local GameEngine GameEngine;
AccessControlRaw = WorldInfo.Game.ParseOption(LoadParams, OptAC);
`Log_Trace();
LoadURL = Repl(LoadURL, Subst(OptMut) $ MutatorsRaw, "");
LoadURL = Repl(LoadURL, Subst(OptAC) $ AccessControlRaw, ""); LoadURL = WorldInfo.GetLocalURL();
LoadParams = Mid(LoadURL, InStr(LoadURL, "?"));
SML.static.ClearMutators(); MutatorsRaw = WorldInfo.Game.ParseOption(LoadParams, OptMut);
ParseStringIntoArray(MutatorsRaw, Mutators, ",", true); AccessControlRaw = WorldInfo.Game.ParseOption(LoadParams, OptAC);
Index = 0; LoadURL = Repl(LoadURL, Subst(OptMut) $ MutatorsRaw, "");
while (Index < Mutators.Length) LoadURL = Repl(LoadURL, Subst(OptAC) $ AccessControlRaw, "");
{
if (SML.static.AddMutator(Mutators[Index]) || SML.static.ClearMutators();
Mutators[Index] ~= SML.static.GetName(Self)) SML.static.ClearServerActors();
{ ParseStringIntoArray(MutatorsRaw, Mutators, ",", true);
Mutators.Remove(Index, 1);
} Index = 0;
else while (Index < Mutators.Length)
{ {
++Index; if (SML.static.AddMutator(Mutators[Index]) ||
} Mutators[Index] ~= SML.static.GetName(Self))
} {
SML.static.StaticSaveConfig(); Mutators.Remove(Index, 1);
}
JoinArray(Mutators, MutatorsRaw); else
LoadURL $= (Subst(OptMut) $ MutatorsRaw); {
if (SML.static.WantsToSpawn()) ++Index;
{ }
LoadURL $= (Subst(OptAC) $ SML.static.GetName()); }
}
GameEngine = GameEngine(Class'Engine'.static.GetEngine());
`Log_Info("Loader modified, do server travel..."); if (GameEngine == None)
{
WorldInfo.ServerTravel(LoadURL, true); `Log_Error("GameEngine is None, skip loading server actors");
} }
else
private static function String Subst(String Option) {
{ PrevServerActorsCount = GameEngine.ServerActors.Length;
return ("?" $ Option $ "=");
} Index = 0;
while (Index < GameEngine.ServerActors.Length)
defaultproperties {
{ if (SML.static.AddServerActor(GameEngine.ServerActors[Index]))
{
GameEngine.ServerActors.Remove(Index, 1);
}
else
{
++Index;
}
}
if (GameEngine.ServerActors.Length != PrevServerActorsCount)
{
GameEngine.SaveConfig();
}
}
SML.static.StaticSaveConfig();
JoinArray(Mutators, MutatorsRaw);
LoadURL $= (Subst(OptMut) $ MutatorsRaw);
if (SML.static.WantsToSpawn())
{
LoadURL $= (Subst(OptAC) $ SML.static.GetName());
}
`Log_Info("Loader modified, do server travel...");
WorldInfo.ServerTravel(LoadURL, true);
WorldInfo.ForceGarbageCollection(true);
}
private static function String Subst(String Option)
{
return ("?" $ Option $ "=");
}
defaultproperties
{
GroupNames.Add("AccessControl")
} }

View File

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

View File

@ -1,155 +1,342 @@
class SafeMutLoader extends KFAccessControl class SafeMutLoader extends KFAccessControl
config(SML); config(SML);
var private Array<Actor> ServerActors; struct CMR
var private config E_LogLevel LogLevel; {
var private config Array<String> Mutators; var String Mutator;
var String Replacement;
public function PreBeginPlay() };
{
`Log_Trace(); var private Array<Actor> ActiveMutators;
var private Array<Actor> ActiveServerActors;
LogLevel = GetLogLevel(); var private Array<CMR> CustomMutReplacements;
var private Array<String> SystemServerActors;
LoadActors(); var private config E_LogLevel LogLevel;
var private config Array<String> Mutators;
Super.PreBeginPlay(); var private config Array<String> ServerActors;
}
public function PreBeginPlay()
private function LoadActors() {
{ LogLevel = GetLogLevel();
local String MutString;
local class<Mutator> MutClass; `Log_Trace();
local class<Actor> ActClass;
local Actor ServerActor; Super.PreBeginPlay();
`Log_Trace(); LoadMutators();
LoadServerActors();
foreach Mutators(MutString) }
{
MutClass = class<Mutator>(DynamicLoadObject(MutString, class'Class')); public function PostBeginPlay()
if (MutClass == None) {
{ `Log_Trace();
`Log_Error("Can't load mutator:" @ MutString);
continue; Super.PostBeginPlay();
}
RestoreServerActors();
ActClass = GetMutReplacement(MutClass);
if (ActClass == None) SetTimer(2.0f, false, nameof(CheckStatus));
{ }
`Log_Warn("Incompatible:" @ MutString @ "(skip)");
continue; private function CheckStatus()
} {
local KFGI_Access KFGIA;
ServerActor = WorldInfo.Spawn(ActClass);
if (ServerActor == None) `Log_Trace();
{
`Log_Error("Can't spawn:" @ MutString); KFGIA = GetKFGIA();
continue; if (KFGIA == None)
} {
`Log_Error("Can't check ranked status");
ServerActors.AddItem(ServerActor); }
`Log_Info("Loaded:" @ MutString); else if (KFGIA.IsRankedGame())
} {
} `Log_Info("Mutators and server actors successfully loaded! Your server is RANKED!");
}
public static function bool AddMutator(String MutString) else
{ {
if (GetMutStringReplacement(MutString) != None) `Log_Warn("Your server is UNRANKED! Check the mutators and server actors you are using. Maybe some of them are incompatible with SML");
{ }
if (default.Mutators.Find(MutString) == INDEX_NONE) }
{
default.Mutators.AddItem(MutString); private function KFGI_Access GetKFGIA()
} {
return true; local KFGameInfo KFGI;
}
if (WorldInfo == None || WorldInfo.Game == None)
return false; {
} return None;
}
public static function ClearMutators()
{ KFGI = KFGameInfo(WorldInfo.Game);
default.Mutators.Length = 0; if (KFGI == None)
} {
return None;
public static function bool WantsToSpawn() }
{
return (default.Mutators.Length > 0); return new(KFGI) class'KFGI_Access';
} }
public static function String GetName(optional Object O) private function LoadMutators()
{ {
if (O == None) local String MutString;
{ local class<Mutator> MutClass;
return (default.class.GetPackageName() $ "." $ String(default.class)); local class<Actor> ActClass;
} local Actor ServerActor;
else
{ `Log_Trace();
return (O.class.GetPackageName() $ "." $ String(O.class));
} foreach Mutators(MutString)
} {
MutClass = class<Mutator>(DynamicLoadObject(MutString, class'Class'));
public function PostLogin(PlayerController C) if (MutClass == None)
{ {
local Actor A; `Log_Error("Can't load mutator:" @ MutString);
continue;
`Log_Trace(); }
if (C != None) ActClass = GetMutReplacement(MutClass);
{ if (ActClass == None)
foreach ServerActors(A) {
{ `Log_Warn("Incompatible:" @ MutString @ "(skip)");
A.GetTargetLocation(C, false); continue;
} }
}
ServerActor = WorldInfo.Spawn(ActClass);
Super.PostLogin(C); if (ServerActor == None)
} {
`Log_Error("Can't spawn:" @ MutString);
public function OnClientConnectionClose(Player ClientConnection) continue;
{ }
local Controller C;
local Actor A; ActiveMutators.AddItem(ServerActor);
`Log_Info("Loaded:" @ MutString);
`Log_Trace(); }
}
C = ClientConnection.Actor;
if (C != None) private function LoadServerActors()
{ {
foreach ServerActors(A) local String ActorString;
{ local class<Actor> ActorClass;
A.GetTargetLocation(C, true); local Actor ServerActor;
}
} foreach ServerActors(ActorString)
{
Super.OnClientConnectionClose(ClientConnection); ActorClass = class<Actor>(DynamicLoadObject(ActorString, class'Class'));
} if (ActorClass == None)
{
public static function E_LogLevel GetLogLevel() `Log_Error("Can't load server actor:" @ ActorString);
{ continue;
if (default.LogLevel == LL_WrongLevel) }
{
default.LogLevel = LL_Info; ServerActor = WorldInfo.Spawn(ActorClass);
StaticSaveConfig(); if (ServerActor == None)
} {
`Log_Error("Can't spawn:" @ ActorString);
return default.LogLevel; continue;
} }
private static function class<Actor> GetMutReplacement(class<Mutator> MutClass) ActiveServerActors.AddItem(ServerActor);
{ `Log_Info("Loaded:" @ ActorString);
if (MutClass == None || MutClass.static.GetLocalString() == "") return None; }
return class<Actor>(DynamicLoadObject( }
MutClass.GetPackageName() $ "." $
MutClass.static.GetLocalString(), class'Class')); private function RestoreServerActors()
} {
local GameEngine GameEngine;
private static function class<Actor> GetMutStringReplacement(String MutString) local String ActorString;
{ local int PrevServerActorsCount;
return GetMutReplacement(class<Mutator>(DynamicLoadObject(MutString, class'Class')));
} GameEngine = GameEngine(Class'Engine'.static.GetEngine());
defaultproperties 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)
{
if (GetMutStringReplacement(MutString) != None)
{
if (default.Mutators.Find(MutString) == INDEX_NONE)
{
default.Mutators.AddItem(MutString);
}
return true;
}
return false;
}
public static function ClearMutators()
{
default.Mutators.Length = 0;
}
public static function ClearServerActors()
{
default.ServerActors.Length = 0;
}
public static function bool WantsToSpawn()
{
return (default.Mutators.Length > 0);
}
public static function String GetName(optional Object O)
{
if (O == None)
{
return (default.class.GetPackageName() $ "." $ String(default.class));
}
else
{
return (O.class.GetPackageName() $ "." $ String(O.class));
}
}
public static function String GetMutName(class<Mutator> CMut)
{
if (CMut == None) return "";
return CMut.GetPackageName() $ "." $ String(CMut);
}
public function PostLogin(PlayerController C)
{
local Actor A;
`Log_Trace();
if (C != None)
{
foreach ActiveMutators(A)
{
A.GetTargetLocation(C, false);
}
}
Super.PostLogin(C);
}
public function OnClientConnectionClose(Player ClientConnection)
{
local Controller C;
local Actor A;
`Log_Trace();
C = ClientConnection.Actor;
if (C != None)
{
foreach ActiveMutators(A)
{
A.GetTargetLocation(C, true);
}
}
Super.OnClientConnectionClose(ClientConnection);
}
public static function E_LogLevel GetLogLevel()
{
if (default.LogLevel == LL_WrongLevel)
{
default.LogLevel = LL_Info;
StaticSaveConfig();
}
return default.LogLevel;
}
private static function class<Actor> GetMutReplacement(class<Mutator> MutClass)
{
local int Index;
local String Replacement;
if (MutClass == None) return None;
Index = default.CustomMutReplacements.Find('Mutator', GetMutName(MutClass));
if (Index != INDEX_NONE)
{
Replacement = default.CustomMutReplacements[Index].Replacement;
}
else if (MutClass.static.GetLocalString() == "")
{
return None;
}
else
{
Replacement = MutClass.GetPackageName() $ "." $ MutClass.static.GetLocalString();
}
return class<Actor>(DynamicLoadObject(Replacement, class'Class'));
}
private static function class<Actor> GetMutStringReplacement(String MutString)
{
return GetMutReplacement(class<Mutator>(DynamicLoadObject(MutString, class'Class')));
}
defaultproperties
{
// Looks like this method is no longer needed to load UKFP
// But I'll leave this commented just in case
/*
CustomMutReplacements.Add({(
Mutator="UnofficialKFPatch.UKFPMutator",
Replacement="UnofficialKFPatch.UKFPReplicationInfo"
)})
CustomMutReplacements.Add({(
Mutator="UnofficialKFPatch.UKFPMutatorNW",
Replacement="UnofficialKFPatch.UKFPReplicationInfo"
)})
*/
SystemServerActors.Add("IpDrv.WebServer")
} }

View File

@ -1,20 +1,20 @@
class _Logger extends Object class _Logger extends Object
abstract; abstract;
enum E_LogLevel enum E_LogLevel
{ {
LL_WrongLevel, LL_WrongLevel,
LL_None, LL_None,
LL_Fatal, LL_Fatal,
LL_Error, LL_Error,
LL_Warning, LL_Warning,
LL_Info, LL_Info,
LL_Debug, LL_Debug,
LL_Trace, LL_Trace,
LL_All LL_All
}; };
defaultproperties defaultproperties
{ {
} }

View File

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

View File

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

View File

@ -1,15 +1,15 @@
// Logger // Logger
`define Log_Tag 'SML' `define Log_Tag 'SML'
`define LocationStatic "`{ClassName}::" $ GetFuncName() `define LocationStatic "`{ClassName}::" $ GetFuncName()
`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag) `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_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag)
`define Log_Error(msg) `log("ERROR:" @ `msg, (LogLevel >= LL_Error), `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_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag)
`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `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_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_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) `define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)

View File

@ -7,7 +7,7 @@ StripSource="True"
# Mutators to be compiled # Mutators to be compiled
# Specify them with a space as a separator, # Specify them with a space as a separator,
# Mutators will be compiled in the specified order # Mutators will be compiled in the specified order
PackageBuildOrder="SML" PackageBuildOrder="SML"
@ -16,7 +16,7 @@ PackageBuildOrder="SML"
# Packages you want to brew using @peelz's patched KFEditor. # Packages you want to brew using @peelz's patched KFEditor.
# Useful for cases where regular brew doesn't put *.upk inside the package. # Useful for cases where regular brew doesn't put *.upk inside the package.
# Specify them with a space as a separator, # Specify them with a space as a separator,
# The order doesn't matter # The order doesn't matter
PackagePeelzBrew="" PackagePeelzBrew=""
@ -24,7 +24,7 @@ PackagePeelzBrew=""
# Mutators that will be uploaded to the workshop # Mutators that will be uploaded to the workshop
# Specify them with a space as a separator, # Specify them with a space as a separator,
# The order doesn't matter # The order doesn't matter
PackageUpload="SML" PackageUpload="SML"

2
tools

@ -1 +1 @@
Subproject commit 88b35bd7ebb7e30448579f1564220398f990541c Subproject commit fb458ac61f7e6c6426b8dff366dd5e7499e0d95f