MapVote changes:

- feat: "MapVote orgy" can be configured or disabled (KFxMapVote.ini);
- fix: Map change at the end of the game in single player mode (#19).
This commit is contained in:
GenZmeY 2021-01-08 22:43:09 +03:00
parent b05328fc6b
commit df1a0ca8f1

View File

@ -6,9 +6,10 @@ struct FGameModeOption
var config string GameName,GameShortName,GameClass,Mutators,Options,Prefix; var config string GameName,GameShortName,GameClass,Mutators,Options,Prefix;
}; };
var config array<FGameModeOption> GameModes; var config array<FGameModeOption> GameModes;
var config int LastVotedGameInfo,VoteTime,MaxMapsOnList; var config int LastVotedGameInfo,VoteTime,MaxMapsOnList,VoteNumForOrgy;
var config float MidGameVotePct,MapWinPct,MapChangeDelay; var config float MidGameVotePct,MapWinPct,MapChangeDelay;
var config bool bNoWebAdmin; var config bool bNoWebAdmin;
var config bool bNoMapVoteOrgy;
var class<Mutator> BaseMutator; var class<Mutator> BaseMutator;
@ -25,6 +26,7 @@ function PostBeginPlay()
{ {
local int i,j,z,n,UpV,DownV,Seq,NumPl; local int i,j,z,n,UpV,DownV,Seq,NumPl;
local string S,MapFile; local string S,MapFile;
local bool ConfigChanged;
if (WorldInfo.Game.BaseMutator==None) if (WorldInfo.Game.BaseMutator==None)
WorldInfo.Game.BaseMutator = Self; WorldInfo.Game.BaseMutator = Self;
@ -33,6 +35,8 @@ function PostBeginPlay()
if (bDeleteMe) // This was a duplicate instance of the mutator. if (bDeleteMe) // This was a duplicate instance of the mutator.
return; return;
ConfigChanged = False;
MapFile = string(WorldInfo.GetPackageName()); MapFile = string(WorldInfo.GetPackageName());
iCurrentHistory = class'xMapVoteHistory'.Static.GetMapHistory(MapFile,WorldInfo.Title); iCurrentHistory = class'xMapVoteHistory'.Static.GetMapHistory(MapFile,WorldInfo.Title);
if (LastVotedGameInfo<0 || LastVotedGameInfo>=GameModes.Length) if (LastVotedGameInfo<0 || LastVotedGameInfo>=GameModes.Length)
@ -51,9 +55,19 @@ function PostBeginPlay()
MidGameVotePct = 0.51; MidGameVotePct = 0.51;
MapWinPct = 0.75; MapWinPct = 0.75;
VoteTime = 35; VoteTime = 35;
SaveConfig(); ConfigChanged = True;
} }
if (VoteNumForOrgy <= 0)
{
VoteNumForOrgy = 4;
bNoMapVoteOrgy = False;
ConfigChanged = True;
}
if (ConfigChanged)
SaveConfig();
// Build maplist. // Build maplist.
z = 0; z = 0;
for (i=(Class'KFGameInfo'.Default.GameMapCycles.Length-1); i>=0; --i) for (i=(Class'KFGameInfo'.Default.GameMapCycles.Length-1); i>=0; --i)
@ -314,9 +328,10 @@ final function TallyVotes(optional bool bForce)
// Finally pick a random winner from the best. // Finally pick a random winner from the best.
c = Candidates[Rand(Candidates.Length)]; c = Candidates[Rand(Candidates.Length)];
if (NumVotees>=4 && ActiveVotes.Length==1) // If more then 4 voters and everyone voted same map?!!! Give the mapvote some orgy. // If more then "VoteNumForOrgy" voters and everyone voted same map?!!! Give the mapvote some orgy.
if (!bNoMapVoteOrgy && NumVotees >= VoteNumForOrgy && ActiveVotes.Length==1)
{ {
for (j=(ActiveVoters.Length-1); j>=0; --j) for (j=(ActiveVoters.Length-1); j >= 0; --j)
ActiveVoters[j].PlayerOwner.ClientPlaySound(AnnouncerCues[13]); ActiveVoters[j].PlayerOwner.ClientPlaySound(AnnouncerCues[13]);
} }
SwitchToLevel(ActiveVotes[c].GameIndex,ActiveVotes[c].MapIndex,false); SwitchToLevel(ActiveVotes[c].GameIndex,ActiveVotes[c].MapIndex,false);
@ -409,7 +424,11 @@ function Timer()
if (bMapvoteHasEnded) if (bMapvoteHasEnded)
{ {
if (WorldInfo.NextSwitchCountdown<=0.f) // Mapswitch failed, force to random other map. // NOTE:
// "WorldInfo.NetMode != NM_Standalone" prevents cyclic unsuccessful map change in single player mode.
// I have not tested how this code will behave if it really fails to change the map.
// Most likely there should be another solution here, but for now it will do.
if (WorldInfo.NetMode != NM_Standalone && WorldInfo.NextSwitchCountdown<=0.f) // Mapswitch failed, force to random other map.
{ {
ActiveVotes.Length = 0; ActiveVotes.Length = 0;
bMapvoteHasEnded = false; bMapvoteHasEnded = false;