abc
This commit is contained in:
parent
af996be243
commit
d8778206b1
@ -1,10 +1,7 @@
|
||||
Class MskGsMut extends KFMutator
|
||||
config(MskGs);
|
||||
|
||||
var const int SteamIDLen;
|
||||
var const int UniqueIDLen;
|
||||
|
||||
var const int CurrentVersion;
|
||||
const CurrentVersion = 2;
|
||||
var config int ConfigVersion;
|
||||
|
||||
var config bool bEnableMapStats;
|
||||
@ -13,7 +10,7 @@ var config bool bOfficialNextMapOnly;
|
||||
var config bool bRandomizeNextMap;
|
||||
var config int WeapDespawnTime;
|
||||
|
||||
var config array<string> ImportantPersonList;
|
||||
var config array<string> KickProtectedList;
|
||||
var config array<int> PerPlayerMaxMonsters;
|
||||
|
||||
function InitMutator(string Options, out string ErrorMessage)
|
||||
@ -62,7 +59,7 @@ function InitConfig()
|
||||
`log("[MskGsMut] Config is up-to-date");
|
||||
break;
|
||||
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: The config version will be changed to "@CurrentVersion);
|
||||
break;
|
||||
@ -125,17 +122,17 @@ function Initialize()
|
||||
|
||||
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)
|
||||
VoteCollector.ImportantPersonList.AddItem(PersonUID);
|
||||
if (VoteCollector.KickProtectedList.Find('Uid', PersonUID.Uid) == -1)
|
||||
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)
|
||||
VoteCollector.ImportantPersonList.AddItem(PersonUID);
|
||||
if (VoteCollector.KickProtectedList.Find('Uid', PersonUID.Uid) == -1)
|
||||
VoteCollector.KickProtectedList.AddItem(PersonUID);
|
||||
}
|
||||
else `Log("[MskGsMut] WARN: Can't add person:"@Person);
|
||||
}
|
||||
@ -170,6 +167,11 @@ function AddMutator(Mutator Mut)
|
||||
Super.AddMutator(Mut);
|
||||
}
|
||||
|
||||
private function bool IsUID(String ID)
|
||||
{
|
||||
return (Left(ID, 2) ~= "0x");
|
||||
}
|
||||
|
||||
function bool CheckRelevance(Actor Other)
|
||||
{
|
||||
local bool SuperRelevant;
|
||||
@ -210,9 +212,23 @@ function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> dam
|
||||
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
|
||||
{
|
||||
SteamIDLen=17
|
||||
UniqueIDLen=18
|
||||
CurrentVersion=2 // Config
|
||||
|
||||
}
|
||||
|
@ -8,57 +8,114 @@ var bool bRandomizeNextMap;
|
||||
|
||||
var private array<string> ActiveMapCycle;
|
||||
|
||||
var public array<UniqueNetId> ImportantPersonList;
|
||||
var private array<KFPlayerController> PunishList;
|
||||
var public array<UniqueNetId> KickProtectedList;
|
||||
|
||||
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 KFGameInfo KFGI;
|
||||
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;
|
||||
}
|
||||
|
||||
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
|
||||
KFGI = KFGameInfo(WorldInfo.Game);
|
||||
|
||||
for (i=0; i < PunishList.Length; i++)
|
||||
LocalKickPunishList = KickPunishList;
|
||||
foreach LocalKickPunishList(KFPC)
|
||||
{
|
||||
KFPC = PunishList[i];
|
||||
if (KFGRI.bMatchHasBegun)
|
||||
{
|
||||
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)
|
||||
{
|
||||
KickPunishList.RemoveItem(KFPC);
|
||||
KickWarningList.RemoveItem(KFPC);
|
||||
KFAccessControl(KFGI.AccessControl).ForceKickPlayer(KFPC, KFGI.AccessControl.KickedMsg);
|
||||
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 string PunishMessage;
|
||||
local KFPlayerController KFPC_Kicker;
|
||||
|
||||
if (ImportantPersonList.Find('Uid', PRI_Kickee.UniqueId.Uid) != -1)
|
||||
{
|
||||
KFPC_Kicker = KFPlayerController(PRI_Kicker.Owner);
|
||||
if (PunishList.Find(KFPC_Kicker) == -1)
|
||||
if (!IsKickerWarned(KFPC_Kicker))
|
||||
{
|
||||
PunishMessage = PRI_Kicker.PlayerName@"tried to kick"@PRI_Kickee.PlayerName@", but sat down on the bottle instead.";
|
||||
WorldInfo.Game.Broadcast(KFPC_Kicker, PunishMessage);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
PunishList.AddItem(KFPC_Kicker);
|
||||
SetTimer(2.0f, false, 'ServerStartPunishment', self);
|
||||
function PunishKicker(PlayerReplicationInfo PRI_Kicker)
|
||||
{
|
||||
local KFPlayerController KFPC_Kicker;
|
||||
|
||||
KFPC_Kicker = KFPlayerController(PRI_Kicker.Owner);
|
||||
if (!IsKickerPunishListed(KFPC_Kicker))
|
||||
{
|
||||
KickPunishList.AddItem(KFPC_Kicker);
|
||||
WorldInfo.Game.Broadcast(KFPC_Kicker, PRI_Kicker.PlayerName@"seems to be feeling bad...");
|
||||
if (!IsTimerActive(nameof(PunishmentTick)))
|
||||
{
|
||||
SetTimer(0.5f, true, nameof(PunishmentTick), self);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerReplicationInfo PRI_Kicker)
|
||||
@ -72,42 +129,44 @@ function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerReplication
|
||||
KFPC = KFPlayerController(PRI_Kicker.Owner);
|
||||
KickeePC = KFPlayerController(PRI_Kickee.Owner);
|
||||
|
||||
// Kick voting is disabled
|
||||
if(KFGI.bDisableKickVote)
|
||||
if (KFGI.bDisableKickVote) // Kick voting is disabled
|
||||
{
|
||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteDisabled);
|
||||
return;
|
||||
}
|
||||
|
||||
// Spectators aren't allowed to vote
|
||||
if(PRI_Kicker.bOnlySpectator)
|
||||
if (PRI_Kicker.bOnlySpectator) // Spectators aren't allowed to vote
|
||||
{
|
||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteNoSpectators);
|
||||
return;
|
||||
}
|
||||
|
||||
// Not enough players to start a vote
|
||||
if( KFGI.NumPlayers <= 2 )
|
||||
if (KFGI.NumPlayers <= 2) // Not enough players to start a vote
|
||||
{
|
||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteNotEnoughPlayers);
|
||||
return;
|
||||
}
|
||||
|
||||
// Maximum number of players kicked per match has been reached
|
||||
if( KickedPlayers >= 2 )
|
||||
if (KickedPlayers >= 2) // Maximum number of players kicked per match has been reached
|
||||
{
|
||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteMaxKicksReached);
|
||||
return;
|
||||
}
|
||||
|
||||
// Bottling
|
||||
if (ImportantKickee(PRI_Kickee, PRI_Kicker))
|
||||
if (IsPlayerKickProtected(PRI_Kickee)) // Bottling
|
||||
{
|
||||
if (IsKickerWarned(KFPC))
|
||||
{
|
||||
PunishKicker(PRI_Kicker);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarnKicker(PRI_Kickee, PRI_Kicker);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Can't kick admins
|
||||
if(KFGI.AccessControl != none)
|
||||
if (KFGI.AccessControl != none) // Can't kick admins
|
||||
{
|
||||
if (KFGI.AccessControl.IsAdmin(KickeePC))
|
||||
{
|
||||
@ -116,15 +175,13 @@ function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerReplication
|
||||
}
|
||||
}
|
||||
|
||||
// Last vote failed, must wait until failed vote cooldown before starting a new vote
|
||||
if( bIsFailedVoteTimerActive )
|
||||
if (bIsFailedVoteTimerActive) // Last vote failed, must wait until failed vote cooldown before starting a new vote
|
||||
{
|
||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_KickVoteRejected);
|
||||
return;
|
||||
}
|
||||
|
||||
// A kick vote is not allowed while another vote is active
|
||||
if(bIsSkipTraderVoteInProgress)
|
||||
if (bIsSkipTraderVoteInProgress) // A kick vote is not allowed while another vote is active
|
||||
{
|
||||
KFPC.ReceiveLocalizedMessage(class'KFLocalMessage', LMT_OtherVoteInProgress);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user