This commit is contained in:
GenZmeY 2023-05-14 10:55:38 +03:00
parent 0cb47d2d0c
commit 5e0c9a3792
8 changed files with 119 additions and 12 deletions

View File

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

View File

@ -1,13 +1,45 @@
class TAWODMut extends KFMutator; class TAWODMut extends KFMutator;
var const E_LogLevel LogLevel;
var private TAWOD TAWOD;
public simulated function bool SafeDestroy()
{
`Log_Trace();
return (bPendingDelete || bDeleteMe || Destroy());
}
public event PreBeginPlay() public event PreBeginPlay()
{ {
`Log_Trace();
Super.PreBeginPlay(); Super.PreBeginPlay();
`log("Loaded.", true, 'TAWOD');
if (WorldInfo.Game.DefaultPawnClass != WorldInfo.Game.default.DefaultPawnClass)
{
`Log_Warn("Custom 'DefaultPawnClass' (" $ WorldInfo.Game.DefaultPawnClass $ ") detected, possible compatibility issues. Turn off TAWOD if there are problems");
}
if (ClassIsChildOf(WorldInfo.Game.DefaultPawnClass, class'KFGameInfo_VersusSurvival'.default.DefaultPawnClass))
{
WorldInfo.Game.DefaultPawnClass = class'TAWOD_PawnHuman_Versus';
`Log_Info("TAWOD_PawnHuman_Versus");
}
else
{
WorldInfo.Game.DefaultPawnClass = class'TAWOD_PawnHuman';
`Log_Info("TAWOD_PawnHuman");
}
`Log_Info("Loaded.");
} }
public function AddMutator(Mutator Mut) public function AddMutator(Mutator Mut)
{ {
`Log_Trace();
if (Mut == Self) return; if (Mut == Self) return;
if (Mut.Class == Class) if (Mut.Class == Class)
@ -18,20 +50,33 @@ public function AddMutator(Mutator Mut)
public function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation) public function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation)
{ {
local KFWeapon TempWeapon; `Log_Trace();
local KFPawn_Human KFP;
KFP = KFPawn_Human(Killed); if (Role >= ROLE_Authority)
{
if (Role >= ROLE_Authority && KFP != None && KFP.InvManager != None) DropAllWeapons(KFPawn_Human(Killed));
foreach KFP.InvManager.InventoryActors(class'KFWeapon', TempWeapon) }
if (TempWeapon != None && TempWeapon.bDropOnDeath && TempWeapon.CanThrow())
KFP.TossInventory(TempWeapon);
return Super.PreventDeath(Killed, Killer, damageType, HitLocation); return Super.PreventDeath(Killed, Killer, damageType, HitLocation);
} }
public static function DropAllWeapons(KFPawn_Human KFP)
{
local KFWeapon KFW;
if (KFP != None && KFP.InvManager != None)
{
foreach KFP.InvManager.InventoryActors(class'KFWeapon', KFW)
{
if (KFW != None && KFW.bDropOnDeath && KFW.CanThrow())
{
KFP.TossInventory(KFW);
}
}
}
}
defaultproperties defaultproperties
{ {
LogLevel = LL_Info
} }

View File

@ -0,0 +1,11 @@
class TAWOD_PawnHuman extends KFPawn_Human;
public function ThrowWeaponOnDeath()
{
class'TAWODMut'.static.DropAllWeapons(Self);
}
defaultproperties
{
}

View File

@ -0,0 +1,11 @@
class TAWOD_PawnHuman_Versus extends KFPawn_Human_Versus;
public function ThrowWeaponOnDeath()
{
class'TAWODMut'.static.DropAllWeapons(Self);
}
defaultproperties
{
}

20
TAWOD/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
TAWOD/Constants.uci Normal file
View File

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

3
TAWOD/Globals.uci Normal file
View File

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

15
TAWOD/Logger.uci Normal file
View File

@ -0,0 +1,15 @@
// Logger
`define Log_Tag 'TAWOD'
`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)