abc
This commit is contained in:
parent
af996be243
commit
d8778206b1
@ -1,10 +1,7 @@
|
|||||||
Class MskGsMut extends KFMutator
|
Class MskGsMut extends KFMutator
|
||||||
config(MskGs);
|
config(MskGs);
|
||||||
|
|
||||||
var const int SteamIDLen;
|
const CurrentVersion = 2;
|
||||||
var const int UniqueIDLen;
|
|
||||||
|
|
||||||
var const int CurrentVersion;
|
|
||||||
var config int ConfigVersion;
|
var config int ConfigVersion;
|
||||||
|
|
||||||
var config bool bEnableMapStats;
|
var config bool bEnableMapStats;
|
||||||
@ -13,7 +10,7 @@ var config bool bOfficialNextMapOnly;
|
|||||||
var config bool bRandomizeNextMap;
|
var config bool bRandomizeNextMap;
|
||||||
var config int WeapDespawnTime;
|
var config int WeapDespawnTime;
|
||||||
|
|
||||||
var config array<string> ImportantPersonList;
|
var config array<string> KickProtectedList;
|
||||||
var config array<int> PerPlayerMaxMonsters;
|
var config array<int> PerPlayerMaxMonsters;
|
||||||
|
|
||||||
function InitMutator(string Options, out string ErrorMessage)
|
function InitMutator(string Options, out string ErrorMessage)
|
||||||
@ -62,7 +59,7 @@ function InitConfig()
|
|||||||
`log("[MskGsMut] Config is up-to-date");
|
`log("[MskGsMut] Config is up-to-date");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
`log("[MskGsMut] Warn: The config version is higher than the current version (are you using an old mutator?)");
|
`log("[MskGsMut] Warn: The config version is higher than the current version");
|
||||||
`log("[MskGsMut] Warn: Config version is"@ConfigVersion@"but current version is"@CurrentVersion);
|
`log("[MskGsMut] Warn: Config version is"@ConfigVersion@"but current version is"@CurrentVersion);
|
||||||
`log("[MskGsMut] Warn: The config version will be changed to "@CurrentVersion);
|
`log("[MskGsMut] Warn: The config version will be changed to "@CurrentVersion);
|
||||||
break;
|
break;
|
||||||
@ -125,17 +122,17 @@ function Initialize()
|
|||||||
|
|
||||||
steamworks = class'GameEngine'.static.GetOnlineSubsystem();
|
steamworks = class'GameEngine'.static.GetOnlineSubsystem();
|
||||||
|
|
||||||
foreach ImportantPersonList(Person)
|
foreach KickProtectedList(Person)
|
||||||
{
|
{
|
||||||
if (Len(Person) == UniqueIDLen && steamworks.StringToUniqueNetId(Person, PersonUID))
|
if (IsUID(Person) && steamworks.StringToUniqueNetId(Person, PersonUID))
|
||||||
{
|
{
|
||||||
if (VoteCollector.ImportantPersonList.Find('Uid', PersonUID.Uid) == -1)
|
if (VoteCollector.KickProtectedList.Find('Uid', PersonUID.Uid) == -1)
|
||||||
VoteCollector.ImportantPersonList.AddItem(PersonUID);
|
VoteCollector.KickProtectedList.AddItem(PersonUID);
|
||||||
}
|
}
|
||||||
else if (Len(Person) == SteamIDLen && steamworks.Int64ToUniqueNetId(Person, PersonUID))
|
else if (steamworks.Int64ToUniqueNetId(Person, PersonUID))
|
||||||
{
|
{
|
||||||
if (VoteCollector.ImportantPersonList.Find('Uid', PersonUID.Uid) == -1)
|
if (VoteCollector.KickProtectedList.Find('Uid', PersonUID.Uid) == -1)
|
||||||
VoteCollector.ImportantPersonList.AddItem(PersonUID);
|
VoteCollector.KickProtectedList.AddItem(PersonUID);
|
||||||
}
|
}
|
||||||
else `Log("[MskGsMut] WARN: Can't add person:"@Person);
|
else `Log("[MskGsMut] WARN: Can't add person:"@Person);
|
||||||
}
|
}
|
||||||
@ -170,6 +167,11 @@ function AddMutator(Mutator Mut)
|
|||||||
Super.AddMutator(Mut);
|
Super.AddMutator(Mut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function bool IsUID(String ID)
|
||||||
|
{
|
||||||
|
return (Left(ID, 2) ~= "0x");
|
||||||
|
}
|
||||||
|
|
||||||
function bool CheckRelevance(Actor Other)
|
function bool CheckRelevance(Actor Other)
|
||||||
{
|
{
|
||||||
local bool SuperRelevant;
|
local bool SuperRelevant;
|
||||||
@ -210,9 +212,23 @@ function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> dam
|
|||||||
return Super.PreventDeath(Killed, Killer, damageType, HitLocation);
|
return Super.PreventDeath(Killed, Killer, damageType, HitLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function NotifyLogin(Controller NewPlayer)
|
||||||
|
{
|
||||||
|
super.NotifyLogin(NewPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
function NotifyLogout(Controller Exiting)
|
||||||
|
{
|
||||||
|
local MskGsVoteCollector VoteCollector;
|
||||||
|
|
||||||
|
VoteCollector = MskGsVoteCollector(MyKFGI.MyKFGRI.VoteCollector);
|
||||||
|
|
||||||
|
VoteCollector.NotifyLogout(Exiting);
|
||||||
|
|
||||||
|
super.NotifyLogout(Exiting);
|
||||||
|
}
|
||||||
|
|
||||||
defaultproperties
|
defaultproperties
|
||||||
{
|
{
|
||||||
SteamIDLen=17
|
|
||||||
UniqueIDLen=18
|
|
||||||
CurrentVersion=2 // Config
|
|
||||||
}
|
}
|
||||||
|
@ -8,57 +8,114 @@ var bool bRandomizeNextMap;
|
|||||||
|
|
||||||
var private array<string> ActiveMapCycle;
|
var private array<string> ActiveMapCycle;
|
||||||
|
|
||||||
var public array<UniqueNetId> ImportantPersonList;
|
var public array<UniqueNetId> KickProtectedList;
|
||||||
var private array<KFPlayerController> PunishList;
|
|
||||||
|
|
||||||
function ServerStartPunishment()
|
var private array<KFPlayerController> KickWarningList;
|
||||||
|
var private array<KFPlayerController> KickPunishList;
|
||||||
|
|
||||||
|
function NotifyLogout(Controller Exiting)
|
||||||
|
{
|
||||||
|
KickWarningList.RemoveItem(KFPlayerController(Exiting));
|
||||||
|
KickPunishList.RemoveItem(KFPlayerController(Exiting));
|
||||||
|
}
|
||||||
|
|
||||||
|
function PunishmentTick()
|
||||||
{
|
{
|
||||||
local KFGameReplicationInfo KFGRI;
|
local KFGameReplicationInfo KFGRI;
|
||||||
local KFGameInfo KFGI;
|
local KFGameInfo KFGI;
|
||||||
local KFPlayerController KFPC;
|
local KFPlayerController KFPC;
|
||||||
local int i;
|
local KFInventoryManager KFIM;
|
||||||
|
local array<KFPlayerController> LocalKickPunishList;
|
||||||
|
|
||||||
if (PunishList.Length == 0)
|
if (KickPunishList.Length == 0)
|
||||||
|
{
|
||||||
|
ClearTimer(nameof(PunishmentTick));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
|
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
|
||||||
KFGI = KFGameInfo(WorldInfo.Game);
|
KFGI = KFGameInfo(WorldInfo.Game);
|
||||||
|
|
||||||
for (i=0; i < PunishList.Length; i++)
|
LocalKickPunishList = KickPunishList;
|
||||||
|
foreach LocalKickPunishList(KFPC)
|
||||||
{
|
{
|
||||||
KFPC = PunishList[i];
|
|
||||||
if (KFGRI.bMatchHasBegun)
|
if (KFGRI.bMatchHasBegun)
|
||||||
{
|
{
|
||||||
KFPC.Suicide();
|
if (KFPC.Pawn.Health <= 1)
|
||||||
|
{
|
||||||
|
KFPC.Suicide();
|
||||||
|
KickPunishList.RemoveItem(KFPC);
|
||||||
|
KickWarningList.RemoveItem(KFPC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KFPC.Pawn.Health--;
|
||||||
|
|
||||||
|
if (KFPawn_Human(KFPC.Pawn).Armor > 0)
|
||||||
|
KFPawn_Human(KFPC.Pawn).Armor--;
|
||||||
|
|
||||||
|
if (KFPC.Pawn.InvManager != None)
|
||||||
|
{
|
||||||
|
KFIM = KFInventoryManager(KFPC.Pawn.InvManager);
|
||||||
|
if (KFIM != None)
|
||||||
|
{
|
||||||
|
KFIM.ThrowMoney();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (KFGI.AccessControl != none)
|
else if (KFGI.AccessControl != none)
|
||||||
{
|
{
|
||||||
|
KickPunishList.RemoveItem(KFPC);
|
||||||
|
KickWarningList.RemoveItem(KFPC);
|
||||||
KFAccessControl(KFGI.AccessControl).ForceKickPlayer(KFPC, KFGI.AccessControl.KickedMsg);
|
KFAccessControl(KFGI.AccessControl).ForceKickPlayer(KFPC, KFGI.AccessControl.KickedMsg);
|
||||||
KFGI.BroadcastLocalized(KFGI, class'KFLocalMessage', LMT_KickVoteSucceeded, CurrentKickVote.PlayerPRI);
|
KFGI.BroadcastLocalized(KFGI, class'KFLocalMessage', LMT_KickVoteSucceeded, CurrentKickVote.PlayerPRI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PunishList.Length = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bool ImportantKickee(PlayerReplicationInfo PRI_Kickee, PlayerReplicationInfo PRI_Kicker)
|
function bool IsPlayerKickProtected(PlayerReplicationInfo PRI_Kickee)
|
||||||
|
{
|
||||||
|
return (KickProtectedList.Find('Uid', PRI_Kickee.UniqueId.Uid) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bool IsKickerWarned(KFPlayerController KFPC)
|
||||||
|
{
|
||||||
|
return (KickWarningList.Find(KFPC) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bool IsKickerPunishListed(KFPlayerController KFPC)
|
||||||
|
{
|
||||||
|
return (KickPunishList.Find(KFPC) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function WarnKicker(PlayerReplicationInfo PRI_Kickee, PlayerReplicationInfo PRI_Kicker)
|
||||||
|
{
|
||||||
|
local KFPlayerController KFPC_Kicker;
|
||||||
|
|
||||||
|
KFPC_Kicker = KFPlayerController(PRI_Kicker.Owner);
|
||||||
|
if (!IsKickerWarned(KFPC_Kicker))
|
||||||
|
{
|
||||||
|
KickWarningList.AddItem(KFPC_Kicker);
|
||||||
|
WorldInfo.Game.Broadcast(KFPC_Kicker, PRI_Kicker.PlayerName@"tried to kick"@PRI_Kickee.PlayerName);
|
||||||
|
WorldInfo.Game.Broadcast(KFPC_Kicker, "If he tries to do it again, the hand of God will punish him");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function PunishKicker(PlayerReplicationInfo PRI_Kicker)
|
||||||
{
|
{
|
||||||
local string PunishMessage;
|
|
||||||
local KFPlayerController KFPC_Kicker;
|
local KFPlayerController KFPC_Kicker;
|
||||||
|
|
||||||
if (ImportantPersonList.Find('Uid', PRI_Kickee.UniqueId.Uid) != -1)
|
KFPC_Kicker = KFPlayerController(PRI_Kicker.Owner);
|
||||||
|
if (!IsKickerPunishListed(KFPC_Kicker))
|
||||||
{
|
{
|
||||||
KFPC_Kicker = KFPlayerController(PRI_Kicker.Owner);
|
KickPunishList.AddItem(KFPC_Kicker);
|
||||||
if (PunishList.Find(KFPC_Kicker) == -1)
|
WorldInfo.Game.Broadcast(KFPC_Kicker, PRI_Kicker.PlayerName@"seems to be feeling bad...");
|
||||||
|
if (!IsTimerActive(nameof(PunishmentTick)))
|
||||||
{
|
{
|
||||||
PunishMessage = PRI_Kicker.PlayerName@"tried to kick"@PRI_Kickee.PlayerName@", but sat down on the bottle instead.";
|
SetTimer(0.5f, true, nameof(PunishmentTick), self);
|
||||||
WorldInfo.Game.Broadcast(KFPC_Kicker, PunishMessage);
|
|
||||||
|
|
||||||
PunishList.AddItem(KFPC_Kicker);
|
|
||||||
SetTimer(2.0f, false, 'ServerStartPunishment', self);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerReplicationInfo PRI_Kicker)
|
function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerReplicationInfo PRI_Kicker)
|
||||||
@ -71,66 +128,66 @@ function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerReplication
|
|||||||
KFGI = KFGameInfo(WorldInfo.Game);
|
KFGI = KFGameInfo(WorldInfo.Game);
|
||||||
KFPC = KFPlayerController(PRI_Kicker.Owner);
|
KFPC = KFPlayerController(PRI_Kicker.Owner);
|
||||||
KickeePC = KFPlayerController(PRI_Kickee.Owner);
|
KickeePC = KFPlayerController(PRI_Kickee.Owner);
|
||||||
|
|
||||||
// Kick voting is disabled
|
if (KFGI.bDisableKickVote) // Kick voting is disabled
|
||||||
if(KFGI.bDisableKickVote)
|
|
||||||
{
|
{
|
||||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteDisabled);
|
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteDisabled);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spectators aren't allowed to vote
|
if (PRI_Kicker.bOnlySpectator) // Spectators aren't allowed to vote
|
||||||
if(PRI_Kicker.bOnlySpectator)
|
|
||||||
{
|
{
|
||||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteNoSpectators);
|
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteNoSpectators);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not enough players to start a vote
|
if (KFGI.NumPlayers <= 2) // Not enough players to start a vote
|
||||||
if( KFGI.NumPlayers <= 2 )
|
|
||||||
{
|
{
|
||||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteNotEnoughPlayers);
|
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteNotEnoughPlayers);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maximum number of players kicked per match has been reached
|
if (KickedPlayers >= 2) // Maximum number of players kicked per match has been reached
|
||||||
if( KickedPlayers >= 2 )
|
|
||||||
{
|
{
|
||||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteMaxKicksReached);
|
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteMaxKicksReached);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottling
|
if (IsPlayerKickProtected(PRI_Kickee)) // Bottling
|
||||||
if (ImportantKickee(PRI_Kickee, PRI_Kicker))
|
|
||||||
{
|
{
|
||||||
|
if (IsKickerWarned(KFPC))
|
||||||
|
{
|
||||||
|
PunishKicker(PRI_Kicker);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarnKicker(PRI_Kickee, PRI_Kicker);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't kick admins
|
if (KFGI.AccessControl != none) // Can't kick admins
|
||||||
if(KFGI.AccessControl != none)
|
|
||||||
{
|
{
|
||||||
if(KFGI.AccessControl.IsAdmin(KickeePC))
|
if (KFGI.AccessControl.IsAdmin(KickeePC))
|
||||||
{
|
{
|
||||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteAdmin);
|
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteAdmin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last vote failed, must wait until failed vote cooldown before starting a new vote
|
if (bIsFailedVoteTimerActive) // Last vote failed, must wait until failed vote cooldown before starting a new vote
|
||||||
if( bIsFailedVoteTimerActive )
|
|
||||||
{
|
{
|
||||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteRejected);
|
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteRejected);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A kick vote is not allowed while another vote is active
|
if (bIsSkipTraderVoteInProgress) // A kick vote is not allowed while another vote is active
|
||||||
if(bIsSkipTraderVoteInProgress)
|
|
||||||
{
|
{
|
||||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_OtherVoteInProgress);
|
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_OtherVoteInProgress);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !bIsKickVoteInProgress )
|
if (!bIsKickVoteInProgress)
|
||||||
{
|
{
|
||||||
// Clear voter array
|
// Clear voter array
|
||||||
PlayersThatHaveVoted.Length = 0;
|
PlayersThatHaveVoted.Length = 0;
|
||||||
@ -149,11 +206,11 @@ function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerReplication
|
|||||||
}
|
}
|
||||||
KFGI.BroadcastLocalized(KFGI, class'KFLocalMessage', LMT_KickVoteStarted, CurrentKickVote.PlayerPRI);
|
KFGI.BroadcastLocalized(KFGI, class'KFLocalMessage', LMT_KickVoteStarted, CurrentKickVote.PlayerPRI);
|
||||||
WorldInfo.Game.Broadcast(KFPC, PRI_Kicker.PlayerName@"starts voting for kick"@PRI_Kickee.PlayerName);
|
WorldInfo.Game.Broadcast(KFPC, PRI_Kicker.PlayerName@"starts voting for kick"@PRI_Kickee.PlayerName);
|
||||||
SetTimer( VoteTime, false, nameof(ConcludeVoteKick), self );
|
SetTimer(VoteTime, false, nameof(ConcludeVoteKick), self );
|
||||||
// Cast initial vote
|
// Cast initial vote
|
||||||
RecieveVoteKick(PRI_Kicker, true);
|
RecieveVoteKick(PRI_Kicker, true);
|
||||||
}
|
}
|
||||||
else if(PRI_Kickee == CurrentKickVote.PlayerPRI)
|
else if (PRI_Kickee == CurrentKickVote.PlayerPRI)
|
||||||
{
|
{
|
||||||
RecieveVoteKick(PRI_Kicker, false);
|
RecieveVoteKick(PRI_Kicker, false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user