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...")
|
||||
self.Data = {}
|
||||
self.Data.StartTime = CurTime()
|
||||
self.Data.RoundTime = 0
|
||||
self.Data.RoundStartTime = 0
|
||||
self.Data.StateTime = 0
|
||||
|
||||
print("Prop Hunt: Initializing Round Manager")
|
||||
self.RoundManager = roundManager(StatePreMatch)
|
||||
@@ -275,12 +277,16 @@ function GM:SetRound(Round)
|
||||
SetGlobalInt("Round", Round)
|
||||
end
|
||||
|
||||
function GM:SetRoundTime(Time)
|
||||
SetGlobalInt("RoundTime", Time)
|
||||
end
|
||||
|
||||
function GM:SetRoundState(State)
|
||||
SetGlobalInt("RoundState", State)
|
||||
end
|
||||
|
||||
function GM:SetRoundTime(Time)
|
||||
SetGlobalInt("RoundTime", Time)
|
||||
function GM:SetRoundStateTime(Time)
|
||||
SetGlobalInt("RoundStateTime", Time)
|
||||
end
|
||||
|
||||
function GM:SetRoundWinner(Winner)
|
||||
|
||||
@@ -29,21 +29,18 @@ StateHide = state("Hide")
|
||||
function StateHide:OnEnter(OldState)
|
||||
if GAMEMODE.Config:DebugLog() then print("StateHide: OnEnter") end
|
||||
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
|
||||
|
||||
function StateHide:Tick()
|
||||
-- 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:SetRoundStateTime(GAMEMODE.Data.StateTime)
|
||||
|
||||
-- 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
|
||||
|
||||
GAMEMODE.RoundManager:SetState(StateSeek)
|
||||
|
||||
@@ -34,11 +34,16 @@ function StatePreRound:OnEnter(OldState)
|
||||
-- Clean Up the Map
|
||||
game.CleanUpMap()
|
||||
|
||||
-- Set Round Start Time
|
||||
GAMEMODE.Data.RoundStartTime = CurTime()
|
||||
|
||||
end
|
||||
|
||||
function StatePreRound:Tick()
|
||||
-- Advance State
|
||||
GAMEMODE.RoundManager:SetState(StateHide)
|
||||
end
|
||||
|
||||
function StatePreRound:OnLeave(NewState)
|
||||
if GAMEMODE.Config:DebugLog() then print("StatePreRound: OnLeave") end
|
||||
|
||||
@@ -60,4 +65,4 @@ function StatePreRound:OnLeave(NewState)
|
||||
|
||||
-- Fretta Hooks
|
||||
hook.Run("RoundStart")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,9 +31,6 @@ function StateSeek:OnEnter(OldState)
|
||||
if GAMEMODE.Config:DebugLog() then print("StateSeek: OnEnter") end
|
||||
GAMEMODE:SetRoundState(GAMEMODE.States.Seek)
|
||||
|
||||
-- Round Data
|
||||
GAMEMODE.Data.RoundTime = GAMEMODE.Config.Round:Time()
|
||||
|
||||
-- Unfreeze Seekers
|
||||
for i, ply in ipairs(team.GetPlayers(GAMEMODE.Teams.Seekers)) do
|
||||
ply:Freeze(false)
|
||||
@@ -45,8 +42,11 @@ end
|
||||
|
||||
function StateSeek:Tick()
|
||||
-- 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:SetRoundStateTime(GAMEMODE.Data.StateTime)
|
||||
|
||||
-- Victory Conditions
|
||||
local hiders, seekers = team.GetPlayers(GAMEMODE.Teams.Hiders), team.GetPlayers(GAMEMODE.Teams.Seekers)
|
||||
@@ -61,7 +61,7 @@ function StateSeek:Tick()
|
||||
end
|
||||
for i,ply in ipairs(seekers) do
|
||||
if (ply.Data.Alive) then
|
||||
seekerAlive = true
|
||||
seekerAlive = truew
|
||||
end
|
||||
end
|
||||
if (hiderAlive == false) then
|
||||
@@ -77,7 +77,7 @@ function StateSeek:Tick()
|
||||
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Hiders)
|
||||
GAMEMODE.RoundManager:SetState(StatePostRound)
|
||||
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.RoundManager:SetState(StatePostRound)
|
||||
end
|
||||
|
||||
@@ -49,7 +49,7 @@ GM.States.PostMatch = 5
|
||||
-- Game Modes
|
||||
GM.Types = {}
|
||||
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
|
||||
GM.Teams = {}
|
||||
@@ -115,12 +115,16 @@ function GM:GetRound()
|
||||
return GetGlobalInt("Round", 0)
|
||||
end
|
||||
|
||||
function GM:GetRoundTime()
|
||||
return GetGlobalInt("RoundTime", 0)
|
||||
end
|
||||
|
||||
function GM:GetRoundState()
|
||||
return GetGlobalInt("RoundState", self.States.PreMatch)
|
||||
end
|
||||
|
||||
function GM:GetRoundTime()
|
||||
return GetGlobalInt("RoundTime", 0)
|
||||
function GM:GetRoundStateTime()
|
||||
return GetGlobalInt("RoundStateTime", 0)
|
||||
end
|
||||
|
||||
function GM:GetRoundWinner()
|
||||
|
||||
Reference in New Issue
Block a user