KF2-MSK-GS/MskGs/Classes/MskGsMut.uc

141 lines
3.3 KiB
Ucode
Raw Normal View History

2021-02-25 23:55:43 +00:00
Class MskGsMut extends KFMutator
config(MskGs);
var const int SteamIDLen;
var const int UniqueIDLen;
var config array<string> ImportantPersonList;
2021-02-20 10:30:45 +00:00
2021-02-26 00:13:55 +00:00
function InitMutator(string Options, out string ErrorMessage)
{
local int MaxPlayers, MaxPlayersAllowed;
super.InitMutator(Options, ErrorMessage);
if (MyKFGI == none)
{
return;
}
2021-03-02 16:15:55 +00:00
MaxPlayers = Clamp(MyKFGI.GetIntOption(Options, "MaxPlayers", MaxPlayers), 6, 128);
2021-02-26 00:13:55 +00:00
MaxPlayersAllowed = MaxPlayers;
MyKFGI.MaxPlayers = MaxPlayers;
MyKFGI.MaxPlayersAllowed = MaxPlayersAllowed;
}
2021-02-20 10:30:45 +00:00
simulated event PostBeginPlay()
{
super.PostBeginPlay();
if (WorldInfo.Game.BaseMutator == None)
WorldInfo.Game.BaseMutator = Self;
else
WorldInfo.Game.BaseMutator.AddMutator(Self);
if (bDeleteMe)
return;
Initialize();
}
function Initialize()
{
2021-02-25 23:55:43 +00:00
local MskGsVoteCollector VoteCollector;
local OnlineSubsystem steamworks;
local string Person;
local UniqueNetId PersonUID;
2021-02-20 10:30:45 +00:00
if (MyKFGI == None || MyKFGI.MyKFGRI == None)
{
SetTimer(2.f, false, nameof(Initialize));
return;
}
MyKFGI.KFGFxManagerClass = class'MskGsGFxMoviePlayer_Manager';
MyKFGI.MyKFGRI.VoteCollectorClass = class'MskGsVoteCollector';
MyKFGI.MyKFGRI.PostBeginPlay();
2021-02-25 23:55:43 +00:00
steamworks = class'GameEngine'.static.GetOnlineSubsystem();
VoteCollector = MskGsVoteCollector(MyKFGI.MyKFGRI.VoteCollector);
if (VoteCollector == None)
{
`Log("[MskGsMut] ERROR: VoteCollector is None!");
return;
}
foreach ImportantPersonList(Person)
{
if (Len(Person) == UniqueIDLen && steamworks.StringToUniqueNetId(Person, PersonUID))
{
if (VoteCollector.ImportantPersonList.Find('Uid', PersonUID.Uid) == -1)
VoteCollector.ImportantPersonList.AddItem(PersonUID);
}
else if (Len(Person) == SteamIDLen && steamworks.Int64ToUniqueNetId(Person, PersonUID))
{
if (VoteCollector.ImportantPersonList.Find('Uid', PersonUID.Uid) == -1)
VoteCollector.ImportantPersonList.AddItem(PersonUID);
}
else `Log("[MskGsMut] WARN: Can't add person:"@Person);
}
2021-02-20 10:30:45 +00:00
`Log("[MskGsMut] Mutator loaded.");
}
function AddMutator(Mutator Mut)
{
if (Mut == Self)
return;
if (Mut.Class == Class)
Mut.Destroy();
else
Super.AddMutator(Mut);
}
2021-03-31 21:27:53 +00:00
function bool CheckRelevance(Actor Other)
{
local bool SuperRelevant;
local KFDroppedPickup PlayerWeap;
SuperRelevant = super.CheckRelevance(Other);
// if this actor is going to be destroyed, return now
if (!SuperRelevant)
{
return SuperRelevant;
}
PlayerWeap = KFDroppedPickup(Other);
// otherwise modify weapon lifespan
if (PlayerWeap != None)
{
PlayerWeap.Lifespan = 2147483647;
return SuperRelevant;
}
return SuperRelevant;
}
2021-03-31 21:29:35 +00:00
function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation)
{
local KFWeapon TempWeapon;
local KFPawn_Human KFP;
KFP = KFPawn_Human(Killed);
if (Role >= ROLE_Authority && KFP != None && KFP.InvManager != none)
foreach KFP.InvManager.InventoryActors(class'KFWeapon', TempWeapon)
if (TempWeapon != none && TempWeapon.bDropOnDeath && TempWeapon.CanThrow())
KFP.TossInventory(TempWeapon);
return Super.PreventDeath(Killed, Killer, damageType, HitLocation);
}
2021-02-20 10:30:45 +00:00
defaultproperties
{
2021-02-25 23:55:43 +00:00
SteamIDLen=17
UniqueIDLen=18
2021-02-20 10:30:45 +00:00
}