Modify time logic to split RoundTime and StateTime
Adds two new functions: - GM:GetRoundStateTime (Shared) - GM:SetRoundStateTime (Server)
This commit is contained in:
@@ -76,7 +76,9 @@ function GM:Initialize()
|
|||||||
|
|
||||||
print("Prop Hunt: Initializing Gamemode Data...")
|
print("Prop Hunt: Initializing Gamemode Data...")
|
||||||
self.Data = {}
|
self.Data = {}
|
||||||
self.Data.StartTime = CurTime()
|
self.Data.RoundTime = 0
|
||||||
|
self.Data.RoundStartTime = 0
|
||||||
|
self.Data.StateTime = 0
|
||||||
|
|
||||||
print("Prop Hunt: Initializing Round Manager")
|
print("Prop Hunt: Initializing Round Manager")
|
||||||
self.RoundManager = roundManager(StatePreMatch)
|
self.RoundManager = roundManager(StatePreMatch)
|
||||||
@@ -275,12 +277,16 @@ function GM:SetRound(Round)
|
|||||||
SetGlobalInt("Round", Round)
|
SetGlobalInt("Round", Round)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GM:SetRoundTime(Time)
|
||||||
|
SetGlobalInt("RoundTime", Time)
|
||||||
|
end
|
||||||
|
|
||||||
function GM:SetRoundState(State)
|
function GM:SetRoundState(State)
|
||||||
SetGlobalInt("RoundState", State)
|
SetGlobalInt("RoundState", State)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GM:SetRoundTime(Time)
|
function GM:SetRoundStateTime(Time)
|
||||||
SetGlobalInt("RoundTime", Time)
|
SetGlobalInt("RoundStateTime", Time)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GM:SetRoundWinner(Winner)
|
function GM:SetRoundWinner(Winner)
|
||||||
|
|||||||
@@ -29,21 +29,18 @@ StateHide = state("Hide")
|
|||||||
function StateHide:OnEnter(OldState)
|
function StateHide:OnEnter(OldState)
|
||||||
if GAMEMODE.Config:DebugLog() then print("StateHide: OnEnter") end
|
if GAMEMODE.Config:DebugLog() then print("StateHide: OnEnter") end
|
||||||
GAMEMODE:SetRoundState(GAMEMODE.States.Hide)
|
GAMEMODE:SetRoundState(GAMEMODE.States.Hide)
|
||||||
|
|
||||||
-- Round Data
|
|
||||||
GAMEMODE.Data.RoundTime = math.abs(GAMEMODE.Config.Round:BlindTime())
|
|
||||||
GAMEMODE.Data.RoundStartTime = CurTime()
|
|
||||||
|
|
||||||
GAMEMODE:SetRoundTime(GAMEMODE.Data.RoundTime)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function StateHide:Tick()
|
function StateHide:Tick()
|
||||||
-- Update Game Time
|
-- Update Game Time
|
||||||
GAMEMODE.Data.RoundTime = math.abs(GAMEMODE.Config.Round:BlindTime()) - (CurTime() - GAMEMODE.Data.RoundStartTime)
|
local deltaTime = (CurTime() - GAMEMODE.Data.RoundStartTime)
|
||||||
|
GAMEMODE.Data.RoundTime = GAMEMODE.Config.Round:Time() - deltaTime
|
||||||
|
GAMEMODE.Data.StateTime = math.abs(GAMEMODE.Config.Round:BlindTime()) - deltaTime
|
||||||
GAMEMODE:SetRoundTime(GAMEMODE.Data.RoundTime)
|
GAMEMODE:SetRoundTime(GAMEMODE.Data.RoundTime)
|
||||||
|
GAMEMODE:SetRoundStateTime(GAMEMODE.Data.StateTime)
|
||||||
|
|
||||||
-- Advance to Seeking State
|
-- Advance to Seeking State
|
||||||
if (GAMEMODE.Data.RoundTime <= 0) then
|
if (GAMEMODE.Data.StateTime <= 0) then
|
||||||
if GAMEMODE.Config:Debug() then print("StateHide: Advancing to Seek stage.") end
|
if GAMEMODE.Config:Debug() then print("StateHide: Advancing to Seek stage.") end
|
||||||
|
|
||||||
GAMEMODE.RoundManager:SetState(StateSeek)
|
GAMEMODE.RoundManager:SetState(StateSeek)
|
||||||
|
|||||||
@@ -34,11 +34,16 @@ function StatePreRound:OnEnter(OldState)
|
|||||||
-- Clean Up the Map
|
-- Clean Up the Map
|
||||||
game.CleanUpMap()
|
game.CleanUpMap()
|
||||||
|
|
||||||
|
-- Set Round Start Time
|
||||||
|
GAMEMODE.Data.RoundStartTime = CurTime()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function StatePreRound:Tick()
|
function StatePreRound:Tick()
|
||||||
-- Advance State
|
-- Advance State
|
||||||
GAMEMODE.RoundManager:SetState(StateHide)
|
GAMEMODE.RoundManager:SetState(StateHide)
|
||||||
end
|
end
|
||||||
|
|
||||||
function StatePreRound:OnLeave(NewState)
|
function StatePreRound:OnLeave(NewState)
|
||||||
if GAMEMODE.Config:DebugLog() then print("StatePreRound: OnLeave") end
|
if GAMEMODE.Config:DebugLog() then print("StatePreRound: OnLeave") end
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,6 @@ function StateSeek:OnEnter(OldState)
|
|||||||
if GAMEMODE.Config:DebugLog() then print("StateSeek: OnEnter") end
|
if GAMEMODE.Config:DebugLog() then print("StateSeek: OnEnter") end
|
||||||
GAMEMODE:SetRoundState(GAMEMODE.States.Seek)
|
GAMEMODE:SetRoundState(GAMEMODE.States.Seek)
|
||||||
|
|
||||||
-- Round Data
|
|
||||||
GAMEMODE.Data.RoundTime = GAMEMODE.Config.Round:Time()
|
|
||||||
|
|
||||||
-- Unfreeze Seekers
|
-- Unfreeze Seekers
|
||||||
for i, ply in ipairs(team.GetPlayers(GAMEMODE.Teams.Seekers)) do
|
for i, ply in ipairs(team.GetPlayers(GAMEMODE.Teams.Seekers)) do
|
||||||
ply:Freeze(false)
|
ply:Freeze(false)
|
||||||
@@ -45,8 +42,11 @@ end
|
|||||||
|
|
||||||
function StateSeek:Tick()
|
function StateSeek:Tick()
|
||||||
-- Update Game Time
|
-- Update Game Time
|
||||||
GAMEMODE.Data.RoundTime = GAMEMODE.Config.Round:Time() - (CurTime() - GAMEMODE.Data.RoundStartTime)
|
local deltaTime = (CurTime() - GAMEMODE.Data.RoundStartTime)
|
||||||
|
GAMEMODE.Data.RoundTime = GAMEMODE.Config.Round:Time() - deltaTime
|
||||||
|
GAMEMODE.Data.StateTime = GAMEMODE.Config.Round:Time() - deltaTime
|
||||||
GAMEMODE:SetRoundTime(GAMEMODE.Data.RoundTime)
|
GAMEMODE:SetRoundTime(GAMEMODE.Data.RoundTime)
|
||||||
|
GAMEMODE:SetRoundStateTime(GAMEMODE.Data.StateTime)
|
||||||
|
|
||||||
-- Victory Conditions
|
-- Victory Conditions
|
||||||
local hiders, seekers = team.GetPlayers(GAMEMODE.Teams.Hiders), team.GetPlayers(GAMEMODE.Teams.Seekers)
|
local hiders, seekers = team.GetPlayers(GAMEMODE.Teams.Hiders), team.GetPlayers(GAMEMODE.Teams.Seekers)
|
||||||
@@ -61,7 +61,7 @@ function StateSeek:Tick()
|
|||||||
end
|
end
|
||||||
for i,ply in ipairs(seekers) do
|
for i,ply in ipairs(seekers) do
|
||||||
if (ply.Data.Alive) then
|
if (ply.Data.Alive) then
|
||||||
seekerAlive = true
|
seekerAlive = truew
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (hiderAlive == false) then
|
if (hiderAlive == false) then
|
||||||
@@ -77,7 +77,7 @@ function StateSeek:Tick()
|
|||||||
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Hiders)
|
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Hiders)
|
||||||
GAMEMODE.RoundManager:SetState(StatePostRound)
|
GAMEMODE.RoundManager:SetState(StatePostRound)
|
||||||
else
|
else
|
||||||
if (GAMEMODE.Data.RoundTime <= 0) then -- No Time remaining
|
if (GAMEMODE.Data.StateTime <= 0) then -- No Time remaining
|
||||||
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Hiders)
|
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Hiders)
|
||||||
GAMEMODE.RoundManager:SetState(StatePostRound)
|
GAMEMODE.RoundManager:SetState(StatePostRound)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ GM.States.PostMatch = 5
|
|||||||
-- Game Modes
|
-- Game Modes
|
||||||
GM.Types = {}
|
GM.Types = {}
|
||||||
GM.Types.Original = 0
|
GM.Types.Original = 0
|
||||||
GM.Types.TheDeadHunt = 1 -- One Hunter, Dead Prop become Hunter, Props can't see each other.
|
GM.Types.TheDeadHunt = 1 -- Deprecated: One Hunter, Dead Prop become Hunter, Props can't see each other.
|
||||||
|
|
||||||
-- Teams
|
-- Teams
|
||||||
GM.Teams = {}
|
GM.Teams = {}
|
||||||
@@ -115,12 +115,16 @@ function GM:GetRound()
|
|||||||
return GetGlobalInt("Round", 0)
|
return GetGlobalInt("Round", 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GM:GetRoundTime()
|
||||||
|
return GetGlobalInt("RoundTime", 0)
|
||||||
|
end
|
||||||
|
|
||||||
function GM:GetRoundState()
|
function GM:GetRoundState()
|
||||||
return GetGlobalInt("RoundState", self.States.PreMatch)
|
return GetGlobalInt("RoundState", self.States.PreMatch)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GM:GetRoundTime()
|
function GM:GetRoundStateTime()
|
||||||
return GetGlobalInt("RoundTime", 0)
|
return GetGlobalInt("RoundStateTime", 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GM:GetRoundWinner()
|
function GM:GetRoundWinner()
|
||||||
|
|||||||
Reference in New Issue
Block a user