Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable time limit #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions Classes/KFGG.uc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class KFGG extends KFGameType
config(KFGunGameGarbage);

var int WarmupTime; // How long to do a pre match warmup before starting the round
var bool bDidWarmup, bDoingWarmup;
var int WarmupCountDown;
var bool bDidWarmup;

var private transient KFGGGameReplicationInfo GG_GRI;
var private transient array<string> WeaponList;
Expand Down Expand Up @@ -77,6 +76,10 @@ event InitGame(string Options, out string Error) {
local KFLevelRules KFLRit;
local ShopVolume SH;
local ZombieVolume ZZ;
local KFGGSettings Settings;

Settings = new(outer) class'KFGGSettings';
TimeLimit = Settings.TimeLimit;

MaxLives = 0;
super(DeathMatch).InitGame(Options, Error);
Expand Down Expand Up @@ -455,7 +458,7 @@ function Killed(Controller Killer, Controller Killed, Pawn KilledPawn, class<Dam
}
}

if (!bDoingWarmup && KFGGPRI(Killer.PlayerReplicationInfo).WeaponLevel >= WeaponList.Length) {
if (!GG_GRI.bDoingWarmup && KFGGPRI(Killer.PlayerReplicationInfo).WeaponLevel >= WeaponList.Length) {
MusicPlaying = true;
CalmMusicPlaying = false;

Expand Down Expand Up @@ -779,7 +782,7 @@ auto State PendingMatch {
function beginstate() {
bWaitingToStartMatch = true;
StartupStage = 0;
WarmupCountDown = WarmupTime;
GG_GRI.WarmupCountDown = WarmupTime;
// if (IsA('xLastManStandingGame') )
// NetWait = Max(NetWait,10);
}
Expand Down Expand Up @@ -851,17 +854,17 @@ state MatchInProgress {
GameReplicationInfo.ElapsedTime = ElapsedTime;

if (!bDidWarmup && WarmupTime > 0) {
WarmupCountDown--;
GG_GRI.WarmupCountDown--;

if (WarmupCountDown <= (default.CountDown - 1) && WarmupCountDown > 0) {
StartupStage = 5 - WarmupCountDown;
if (GG_GRI.WarmupCountDown <= (default.CountDown - 1) && GG_GRI.WarmupCountDown > 0) {
StartupStage = 5 - GG_GRI.WarmupCountDown;
PlayStartupMessage();
}

if (WarmupCountDown <= 0) {
if (GG_GRI.WarmupCountDown <= 0) {
ResetBeforeMatchStart();
bDidWarmup = true;
bDoingWarmup = false;
GG_GRI.bDoingWarmup = false;
StartMatch();

for (C = Level.ControllerList; C != none; C = C.nextController) {
Expand All @@ -881,7 +884,7 @@ state MatchInProgress {
StartupStage = 6;

} else {
bDoingWarmup = true;
GG_GRI.bDoingWarmup = true;
}
} else {
bDidWarmup = true;
Expand Down
4 changes: 3 additions & 1 deletion Classes/KFGGGameReplicationInfo.uc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ class KFGGGameReplicationInfo extends KFGameReplicationInfo;
const MAXWEAPONS=100; // 100 is more than enough for all vanilla weapons + custom gg ones
var byte MaxWeaponLevel; // The maximum weapon level before someone wins the match
var int WarmupTime; // How long to do a pre match warmup before starting the round
var int WarmupCountDown;
var bool bDoingWarmup;
var string weapons[MAXWEAPONS];

replication {
reliable if (Role == ROLE_Authority)
MaxWeaponLevel, WarmupTime, weapons;
MaxWeaponLevel, WarmupTime, weapons, WarmupCountDown, bDoingWarmup;
}

// load all required stuff from `KFGGSettings`
Expand Down
18 changes: 13 additions & 5 deletions Classes/KFGGScoreBoard.uc
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,30 @@ var localized string WeaponLevelString;
function DrawTitle(Canvas Canvas, float HeaderOffsetY, float PlayerAreaY, float PlayerBoxSizeY) {
local string TitleString, ScoreInfoString, RestartString;
local float TitleXL, ScoreInfoXL, YL, TitleY, TitleYL;
local KFGGGameReplicationInfo GG_GRI;

GG_GRI = KFGGGameReplicationInfo(GRI);
TitleString = GameTypeTitleString @
"|" @
MaxWeaponLevelString $
":" @
KFGGGameReplicationInfo(GRI).MaxWeaponLevel @
GG_GRI.MaxWeaponLevel @
"|" @
Level.Title;

Canvas.Font = class'ROHud'.static.GetSmallMenuFont(Canvas);
Canvas.StrLen(TitleString, TitleXL, TitleYL);

if (GRI.TimeLimit != 0) {
ScoreInfoString = TimeLimit $ FormatTime(GRI.RemainingTime);
} else {
ScoreInfoString = FooterText @ FormatTime(GRI.ElapsedTime);
if(GG_GRI != none && GG_GRI.bDoingWarmup){
ScoreInfoString = "WARMUP:" $ FormatTime(GG_GRI.WarmupTime - GRI.ElapsedTime);
}
else
{
if (GRI.TimeLimit != 0) {
ScoreInfoString = TimeLimit $ FormatTime(GRI.RemainingTime);
} else {
ScoreInfoString = FooterText @ FormatTime(GRI.ElapsedTime);
}
}

Canvas.DrawColor = HUDClass.default.RedColor;
Expand Down
2 changes: 2 additions & 0 deletions Classes/KFGGSettings.uc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class KFGGSettings extends Object
const INI="KFGunGameSettings";

var config int WarmupTime; // How long to do a pre match warmup before starting the round
var config int TimeLimit; // How long should the match be
var config string WeaponListName; // what weapon list to use
var transient array<string> Weapons; // weapons!

Expand Down Expand Up @@ -44,5 +45,6 @@ simulated function array<string> GetAllWeaponLists() {
defaultproperties {
// defaults in case someone forgets about config
WarmupTime=30
TimeLimit=15
WeaponListName="Default"
}
2 changes: 2 additions & 0 deletions Configs/KFGunGameSettings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
;= Home repo: https://github.com/InsultingPros/KFGunGame
;= how long to do a pre match warmup before starting the round
WarmupTime=25
;= how many minutes should the game last (does not include warmup)
TimeLimit=15
;= what weapon list to use
WeaponListName=Default

Expand Down