Bringing the repository back up to speed with the workshop mod.

This commit is contained in:
Michael Fabain Dirks
2016-06-15 11:58:55 +02:00
parent 441b32cc8c
commit c556fc6015
23 changed files with 344 additions and 190 deletions
@@ -27,6 +27,8 @@
-- ------------------------------------------------------------------------- --
include("sh_init.lua")
GM.UI = {}
include("client/cl_ui_help.lua")
include("client/cl_ui_teamselection.lua")
-- ------------------------------------------------------------------------- --
@@ -44,7 +46,6 @@ function GM:Initialize()
print("Prop Hunt CL: Complete.")
print("-------------------------------------------------------------------------")
end
function GM:Think() end
@@ -82,88 +83,6 @@ function GM:PlayerSpawn()
player_manager.RunClass(LocalPlayer(), "ClientSpawn")
end
function GM:HUDPaint()
local State = GetGlobalInt("RoundState", GAMEMODE.States.PreMatch)
-- Show Status at the top center
local statusX, statusY, statusW, statusH
statusW = 192
statusH = 64
statusX = ScrW() / 2 - statusW / 2
statusY = 16
--! States
-- Pre Match
if (State == GAMEMODE.States.PreMatch) then
-- Show Status at the top center
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetFont( "Trebuchet24" )
surface.SetTextColor( 255, 255, 255, 255 )
local w,h = surface.GetTextSize("Waiting...")
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/2 - h / 2)
surface.DrawText( "Waiting..." )
-- Pre Round
elseif (State == GAMEMODE.States.PreRound) then
-- Show Status at the top center
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetFont( "Trebuchet24" )
surface.SetTextColor( 255, 255, 255, 255 )
local w,h = surface.GetTextSize("Preparing...")
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/2 - h / 2)
surface.DrawText( "Preparing..." )
-- Hide!
elseif (State == GAMEMODE.States.Hide) then
local strTime = tostring(math.ceil(GetGlobalInt("RoundTime")))
-- Show Status at the top center
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetTextColor(255,255,255,255)
surface.SetFont("Trebuchet18")
local w,h = surface.GetTextSize("Seekers unblinded in:")
surface.SetTextPos(statusX + statusW/2 - w / 2, statusY + statusH/4 - h / 2)
surface.DrawText("Seekers unblinded in:")
surface.SetFont( "Trebuchet24" )
local w,h = surface.GetTextSize(strTime.." Seconds!")
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/1.5 - h / 2)
surface.DrawText(strTime.." Seconds!")
elseif (State == GAMEMODE.States.Seek) then
local intTime = math.ceil(GetGlobalInt("RoundTime"))
local strTime = string.format("%d:%02d", math.floor(intTime / 60), math.ceil(intTime % 60))
-- Show Status at the top center
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetTextColor(255,255,255,255)
surface.SetFont("Trebuchet18")
local w,h = surface.GetTextSize("Hunting Time!")
surface.SetTextPos(statusX + statusW/2 - w / 2, statusY + statusH/4 - h / 2)
surface.DrawText("Hunting Time!")
surface.SetFont( "Trebuchet24" )
local w,h = surface.GetTextSize(strTime)
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/1.5 - h / 2)
surface.DrawText(strTime)
elseif (State == GAMEMODE.States.PostRound) then
elseif (State == GAMEMODE.States.PostMatch) then
end
player_manager.RunClass(LocalPlayer(), "HUDPaint")
end
function GM:ShowTeamSelection()
TeamSelectionUI:Show()
end
concommand.Add("ph_select_team", function() GAMEMODE:ShowTeamSelection() end)
function GM:GetHandsModel()
return player_manager.RunClass(LocalPlayer(), "GetHandsModel")
end
function GM:PostDrawViewModel( vm, ply, weapon )
if ( weapon.UseHands || !weapon:IsScripted() ) then
local hands = LocalPlayer():GetHands()
@@ -174,9 +93,9 @@ end
-- ------------------------------------------------------------------------- --
--! Player Manager Binding
-- ------------------------------------------------------------------------- --
function GM:CalcView(ply, pos, ang, fov, nearZ, farZ)
return player_manager.RunClass(LocalPlayer(), "CalcView", {origin = pos, angles = ang, fov = fov, znear = nearZ, zfar = farZ})
end
function GM:HUDPaint() player_manager.RunClass(LocalPlayer(), "HUDPaint") end
function GM:CalcView(ply, pos, ang, fov, nearZ, farZ) return player_manager.RunClass(LocalPlayer(), "CalcView", {origin = pos, angles = ang, fov = fov, znear = nearZ, zfar = farZ}) end
function GM:GetHandsModel() return player_manager.RunClass(LocalPlayer(), "GetHandsModel") end
-- ------------------------------------------------------------------------- --
--! Gamemode Functionality
@@ -231,6 +150,28 @@ function GM:OnContextMenuClose()
LocalPlayer().Data.ThirdPerson = !LocalPlayer().Data.ThirdPerson
end
function GM:OnSpawnMenuOpen()
print("Prop Hunt CL: Enabling Prop Rotation")
LocalPlayer():SetNWBool("PropRotation", true)
net.Start("PlayerEnablePropRotation");net.SendToServer()
end
function GM:OnSpawnMenuClose()
print("Prop Hunt CL: Disabling Prop Rotation")
LocalPlayer():SetNWBool("PropRotation", false)
net.Start("PlayerDisablePropRotation");net.SendToServer()
end
function GM:ShowHelpUI()
self.UI.Help:Show()
end
concommand.Add("ph_show_help", function() GAMEMODE:ShowHelpUI() end)
function GM:ShowTeamSelection()
TeamSelectionUI:Show()
end
concommand.Add("ph_select_team", function() GAMEMODE:ShowTeamSelection() end)
-- ------------------------------------------------------------------------- --
--! Network Messages
-- ------------------------------------------------------------------------- --
@@ -0,0 +1,61 @@
--[[
The MIT License (MIT)
Copyright (c) 2015 Xaymar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--]]
local PANEL = vgui.Create("DFrame")
PANEL:SetSize(400, 300)
PANEL:SetTitle("Help")
PANEL:SetDraggable(true)
PANEL:SetVisible(false)
PANEL:SetDraggable(true)
PANEL:SetSizable(true)
PANEL:ShowCloseButton(true)
PANEL:SetDeleteOnClose(false)
function PANEL:Init()
DFrame.Init(self)
-- Sheets
self.Sheets = vgui.Create("DPropertySheet", self)
self.Sheets:Dock(FILL)
-- Basic Info
self.BasicInfoSheet = vgui.Create("DPanel", self.Sheets)
function self.BasicInfoSheet:Paint(w, h)
draw.RoundedBox(4, 0, 0, 100, 100, Color(0,128,255))
end
self.Sheets:AddSheet("The Gamemode", self.BasicInfoSheet)
end
function PANEL:Show()
self:SetSize(ScrW(), ScrH())
self:Center()
self:SetVisible(true)
self:SetFocusTopLevel(true)
self:SlideDown(.5)
self:MakePopup()
end
GAMEMODE.UI.Help = PANEL
@@ -36,6 +36,7 @@ AddCSLuaFile("player_class/class_hider.lua")
-- Client-Only
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("client/cl_ui_help.lua")
AddCSLuaFile("client/cl_ui_teamselection.lua")
-- ------------------------------------------------------------------------- --
@@ -53,6 +54,7 @@ include "server/states/state_preround.lua"
include "server/states/state_hide.lua"
include "server/states/state_seek.lua"
include "server/states/state_postround.lua"
include "server/states/state_postmatch.lua"
function GM:Initialize()
print("-------------------------------------------------------------------------")
@@ -66,6 +68,8 @@ function GM:Initialize()
util.AddNetworkString("PlayerResetHull")
util.AddNetworkString("PlayerViewOffset")
util.AddNetworkString("PlayerRegisterPropEntity")
util.AddNetworkString("PlayerEnablePropRotation")
util.AddNetworkString("PlayerDisablePropRotation")
print("Prop Hunt: Initializing Gamemode Data...")
self.Data = {}
@@ -219,6 +223,14 @@ function GM:SetRoundState(State)
SetGlobalInt("RoundState", State)
end
function GM:SetRoundTime(Time)
SetGlobalInt("RoundTime", Time)
end
function GM:SetRoundWinner(Winner)
SetGlobalInt("RoundWinner", Winner)
end
function GM:PlayerHullFromEntity(ply, ent)
if (ent) && (ent:IsValid()) then
local hmin, hmax = ent:OBBMins(), ent:OBBMaxs()
@@ -268,7 +280,9 @@ end
--! Commands
-- ------------------------------------------------------------------------- --
-- F1/ShowHelp
function GM:ShowHelp(ply) end
function GM:ShowHelp(ply)
ply:ConCommand("ph_show_help")
end
-- F2/ShowTeam - Select Team
function GM:ShowTeam(ply)
@@ -305,6 +319,19 @@ concommand.Add("ph_debug_printplayers", function(ply, cmd, args, argStr)
end, nil, nil, FCVAR_CLIENTCMD_CAN_EXECUTE + FCVAR_CHEAT)
-- ------------------------------------------------------------------------- --
--! Network Messages
-- ------------------------------------------------------------------------- --
net.Receive("PlayerEnablePropRotation", function(len, ply)
print("Prop Hunt: Enabling Prop Rotation")
ply:SetNWBool("PropRotation", true)
end)
net.Receive("PlayerDisablePropRotation", function(len, ply)
print("Prop Hunt: Disabling Prop Rotation")
ply:SetNWBool("PropRotation", false)
end)
-- ------------------------------------------------------------------------- --
--! LEGACY CODE - TO BE REPLACED SOON
-- ------------------------------------------------------------------------- --
@@ -67,7 +67,7 @@ function CLASS:PostDeath() end
function CLASS:DoDeath() end
function CLASS:DeathThink()
if (CurTime() - self.Player.Data.AliveTime) > 2 then
if (CurTime() - self.Player.Data.AliveTime) > 5 then
self.Player:Spawn()
return true
end
@@ -128,7 +128,91 @@ function CLASS:ClientSpawn() end
-- View & HUD
function CLASS:GetHandsModel() return BaseClass.GetHandsModel(self) end
function CLASS:ShouldDrawLocal() return false end
function CLASS:HUDPaint() end
function CLASS:HUDPaint()
local State = GetGlobalInt("RoundState", GAMEMODE.States.PreMatch)
-- Show Status at the top center
local statusX, statusY, statusW, statusH
statusW = 192
statusH = 64
statusX = ScrW() / 2 - statusW / 2
statusY = 16
-- Status
if (State == GAMEMODE.States.PreMatch) then -- Pre Match
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetFont( "Trebuchet24" )
surface.SetTextColor( 255, 255, 255, 255 )
local w,h = surface.GetTextSize("Waiting for Players")
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/2 - h / 2)
surface.DrawText("Waiting for Players")
elseif (State == GAMEMODE.States.PreRound) then -- Pre Round
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetFont( "Trebuchet24" )
surface.SetTextColor( 255, 255, 255, 255 )
local w,h = surface.GetTextSize("Preparing...")
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/2 - h / 2)
surface.DrawText( "Preparing..." )
elseif (State == GAMEMODE.States.Hide) then -- Hide
local strTime = tostring(math.ceil(GetGlobalInt("RoundTime")))
-- Show Status at the top center
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetTextColor(255,255,255,255)
surface.SetFont("Trebuchet18")
local w,h = surface.GetTextSize("Seekers unblinded in:")
surface.SetTextPos(statusX + statusW/2 - w / 2, statusY + statusH/4 - h / 2)
surface.DrawText("Seekers unblinded in:")
surface.SetFont( "Trebuchet24" )
local w,h = surface.GetTextSize(strTime.." Seconds!")
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/1.5 - h / 2)
surface.DrawText(strTime.." Seconds!")
elseif (State == GAMEMODE.States.Seek) then -- Seek
local intTime = math.ceil(GetGlobalInt("RoundTime"))
local strTime = string.format("%d:%02d", math.floor(intTime / 60), math.ceil(intTime % 60))
-- Show Status at the top center
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetTextColor(255,255,255,255)
surface.SetFont("Trebuchet18")
local w,h = surface.GetTextSize("Hunting Time!")
surface.SetTextPos(statusX + statusW/2 - w / 2, statusY + statusH/4 - h / 2)
surface.DrawText("Hunting Time!")
surface.SetFont( "Trebuchet24" )
local w,h = surface.GetTextSize(strTime)
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/1.5 - h / 2)
surface.DrawText(strTime)
elseif (State == GAMEMODE.States.PostRound) then -- Post Round
-- Show Status at the top center
draw.RoundedBox(16, statusX, statusY, statusW, statusH, Color(0, 0, 0, 204))
surface.SetTextColor(255,255,255,255)
surface.SetFont("Trebuchet18")
local w,h = surface.GetTextSize("Match Result")
surface.SetTextPos(statusX + statusW/2 - w / 2, statusY + statusH/4 - h / 2)
surface.DrawText("Match Result")
local victor = GAMEMODE:GetRoundWinner()
local victorName = "Unknown"
if (victor == GAMEMODE.Teams.Spectator) then
victorName = "Draw"
elseif (victor == GAMEMODE.Teams.Hiders) then
victorName = "Hiders Win"
elseif (victor == GAMEMODE.Teams.Seekers) then
victorName = "Seekers Win"
end
surface.SetTextColor(team.GetColor(victor))
surface.SetFont( "Trebuchet24" )
local w,h = surface.GetTextSize(victorName)
surface.SetTextPos( statusX + statusW/2 - w / 2, statusY + statusH/1.5 - h / 2)
surface.DrawText(victorName)
elseif (State == GAMEMODE.States.PostMatch) then -- Post Match
end
end
function CLASS:CalcView(camdata) return camdata end
-- ------------------------------------------------------------------------- --
@@ -74,7 +74,12 @@ function CLASS:PostDeath(attacker, dmginfo)
BaseClass.PostDeath(self, inflictor, attacker)
-- Delete Hands Model
self.Player:GetHands():Remove()
if IsValid(self.Player:GetHands()) then
self.Player:GetHands():Remove()
end
if IsValid(self.Player.Data.Prop) then
self.Player.Data.Prop:Remove()
end
-- Collision Group
self.Player:SetCollisionGroup(COLLISION_GROUP_PLAYER)
@@ -186,14 +191,14 @@ function CLASS:CalcView(camdata)
end
-- Incremental Distance instead of instant.
viewDist = math.Clamp(viewDist * 0.9 + maxViewDist * 0.1, 0, maxViewDist) -- Zoom Out
viewDist = math.Clamp(viewDist * 0.95 + maxViewDist * 0.05, 0, maxViewDist) -- Zoom Out
else
if (IsValid(self.Player:GetHands())) then
self.Player:GetHands():SetRenderMode(RENDERMODE_TRANSALPHA)
self.Player:GetHands():SetColor(Color(255, 255, 255, 0))
end
viewDist = math.Clamp(viewDist * 0.9, 0, maxViewDist) -- Zoom In
viewDist = math.Clamp(viewDist * 0.95, 0, maxViewDist) -- Zoom In
end
-- Trace from Player to would-be camera position
@@ -94,7 +94,7 @@ function CLASS:DamageEntity(ent, att, dmg)
if IsValid(ent) && (!(ent:IsPlayer())) then
if (ent:GetClass() == "ph_prop") then
ent:GetOwner():TakeDamageInfo(dmg)
elseif (ent:GetClass() == "func_breakable") then -- ToDo: Make Configurable which entities don't hurt
elseif (ent:GetClass() == "func_breakable") then -- ToDo: Make Configurable which entities don't hurt?
else
att:TakeDamage(GAMEMODE.Config.Seeker:HealthPenalty(), ent, ent)
end
@@ -157,14 +157,13 @@ function CLASS:ClientSpawn()
end
function CLASS:HUDPaint()
BaseClass.HUDPaint(self)
local State = GetGlobalInt("RoundState", GAMEMODE.States.PreMatch)
if (State == GAMEMODE.States.Hide) then
local intTime = math.ceil(GetGlobalInt("RoundTime"))
local strTime = tostring(intTime)
-- Seekers are blinded in this Phase.
draw.RoundedBox(0, 0, 0, surface.ScreenWidth(), surface.ScreenHeight(), Color(0, 0, 0, 255))
-- Show Status at the center
surface.SetTextColor( 255, 255, 255, 255 )
if (intTime >= 1) then
@@ -192,9 +191,9 @@ function CLASS:CalcView(camdata)
-- First/Third
if (self.Player.Data.ThirdPerson) then
viewDist = math.Clamp(viewDist * 0.9 + maxViewDist * 0.1, 0, maxViewDist) -- Zoom Out
viewDist = math.Clamp(viewDist * 0.95 + maxViewDist * 0.05, 0, maxViewDist) -- Zoom Out
else
viewDist = math.Clamp(viewDist * 0.9, 0, maxViewDist) -- Zoom In
viewDist = math.Clamp(viewDist * 0.95, 0, maxViewDist) -- Zoom In
end
-- Trace from Player to would-be camera position
@@ -168,8 +168,8 @@ GM.Config.Lists.ModelBlacklist = {}
GM.Config.Lists.ModelBlacklist["models/props/cs_assault/dollar.mdl"] = true
GM.Config.Lists.ModelBlacklist["models/props/cs_assault/money.mdl"] = true
GM.Config.Lists.ModelBlacklist["models/props/cs_office/snowman_arm.mdl"] = true
GM.Config.Lists.ModelBlacklist["models/props_junk/garbage_plasticbottle001a.mdl"] = true
GM.Config.Lists.ModelBlacklist["models/props/cs_office/projector_remote.mdl"] = true
--GM.Config.Lists.ModelBlacklist["models/props_junk/garbage_plasticbottle001a.mdl"] = true
GM.Config.Lists.ConCmds.ModelBlacklistList = concommand.Add("ph_list_model_blacklist_list", function(ply, cmd, args, argStr)
print("Model Blacklist:")
@@ -32,19 +32,13 @@ function StateHide:OnEnter(OldState)
GAMEMODE.Data.RoundTime = math.abs(GAMEMODE.Config.Round:BlindTime())
GAMEMODE.Data.RoundStartTime = CurTime()
SetGlobalInt("RoundTime", GAMEMODE.Data.RoundTime)
-- Freeze Seekers
for i, ply in ipairs(team.GetPlayers(GAMEMODE.Teams.Seekers)) do
ply:Freeze(true)
ply:Lock()
end
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)
SetGlobalInt("RoundTime", math.ceil(GAMEMODE.Data.RoundTime))
GAMEMODE:SetRoundTime(GAMEMODE.Data.RoundTime)
-- Advance to Seeking State
if (GAMEMODE.Data.RoundTime <= 0) then
@@ -53,6 +47,13 @@ function StateHide:Tick()
GAMEMODE.RoundManager:SetState(StateSeek)
end
-- Freeze Seekers
for i, ply in ipairs(team.GetPlayers(GAMEMODE.Teams.Seekers)) do
ply:Freeze(true)
ply:Lock()
ply:ScreenFade(SCREENFADE.IN, color_black, 1, 9999)
end
-- ToDo: Logic for more game modes here?
end
@@ -26,7 +26,7 @@ StatePostMatch = {}
function StatePostMatch:OnEnter(OldState)
if GAMEMODE.Config:Debug() then print("StatePostMatch: OnEnter") end
GAMEMODE:SetRoundState(GAMEMODE.States.PostMatch)
GAMEMODE:SetRoundState(GAMEMODE.States.PostMatch)
end
function StatePostMatch:Tick()
@@ -27,11 +27,15 @@ StatePostRound = {}
function StatePostRound:OnEnter(OldState)
if GAMEMODE.Config:Debug() then print("StatePostRound: OnEnter") end
GAMEMODE:SetRoundState(GAMEMODE.States.PostRound)
GAMEMODE.Data.RoundStartTime = CurTime()
end
function StatePostRound:Tick()
-- Advance State
GAMEMODE.RoundManager:SetState(StatePreRound) -- Test: Reset to Hide
if (CurTime() - GAMEMODE.Data.RoundStartTime) >= 5 then -- ToDo: configureable time?
GAMEMODE.RoundManager:SetState(StatePostMatch)
end
end
function StatePostRound:OnLeave(NewState)
@@ -42,12 +46,12 @@ function StatePostRound:OnLeave(NewState)
-- Swap Teams
local hiders, seekers = team.GetPlayers(GAMEMODE.Teams.Hiders), team.GetPlayers(GAMEMODE.Teams.Seekers)
for i, ply in ipairs(hiders) do
ply:KillSilent()
ply:SetTeam(GAMEMODE.Teams.Seekers)
player_manager.SetPlayerClass(ply, "Seeker")
end
for i, ply in ipairs(seekers) do
ply:KillSilent()
ply:SetTeam(GAMEMODE.Teams.Hiders)
player_manager.SetPlayerClass(ply, "Hider")
end
-- TODO: Other Gamemodes
@@ -39,14 +39,12 @@ end
function StatePreRound:OnLeave(NewState)
if GAMEMODE.Config:Debug() then print("StatePreRound: OnLeave") end
-- Game Mode: Basic
if (GAMEMODE.Config:GameMode() == GAMEMODE.Modes.Original) then
-- Respawn Everyone
for i, ply in ipairs(player.GetAll()) do
ply:KillSilent()
ply.Data.Alive = true
ply:Spawn()
end
-- TODO: Other Gamemodes
-- Respawn Everyone
for i, ply in ipairs(player.GetAll()) do
ply:KillSilent()
ply.Data.Alive = true
ply:Spawn()
ply:ScreenFade(SCREENFADE.PURGE, color_black, 0, 0)
ply:ScreenFade(SCREENFADE.IN, color_black, 1, 0)
end
end
@@ -35,23 +35,22 @@ function StateSeek:OnEnter(OldState)
for i, ply in ipairs(team.GetPlayers(GAMEMODE.Teams.Seekers)) do
ply:Freeze(false)
ply:UnLock()
ply:ScreenFade(SCREENFADE.PURGE, color_black, 0, 0)
ply:ScreenFade(SCREENFADE.IN, color_black, 1, 0)
end
end
function StateSeek:Tick()
-- Update Game Time
GAMEMODE.Data.RoundTime = GAMEMODE.Config.Round:Time() - (CurTime() - GAMEMODE.Data.RoundStartTime)
SetGlobalInt("RoundTime", math.ceil(GAMEMODE.Data.RoundTime))
GAMEMODE:SetRoundTime(GAMEMODE.Data.RoundTime)
-- Conditions for moving to the next State
if (GAMEMODE.Data.RoundTime <= 0) then -- No Time remaining
GAMEMODE.Data.Winner = GAMEMODE.Teams.Hiders
GAMEMODE.RoundManager:SetState(StatePostRound)
end
-- Condition: No Seekers / Hiders alive.
-- Victory Conditions
local hiders, seekers = team.GetPlayers(GAMEMODE.Teams.Hiders), team.GetPlayers(GAMEMODE.Teams.Seekers)
local hiderAlive, seekerAlive = false, false
if GAMEMODE.Config:Debug() then
hiderAlive = true;seekerAlive = true
end
for i,ply in ipairs(hiders) do
if (ply.Data.Alive) then
hiderAlive = true
@@ -63,17 +62,22 @@ function StateSeek:Tick()
end
end
if (hiderAlive == false) then
if (seekerAlive == false) then
GAMEMODE.Data.Winner = GAMEMODE.Teams.Spectators -- Shows as Draw
if (seekerAlive == false) then -- Draw, both teams dead.
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Spectators)
GAMEMODE.RoundManager:SetState(StatePostRound)
else
GAMEMODE.Data.Winner = GAMEMODE.Teams.Seekers
else -- Seeker victory, Hiders dead
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Seekers)
GAMEMODE.RoundManager:SetState(StatePostRound)
end
else
if (seekerAlive == false) then
GAMEMODE.Data.Winner = GAMEMODE.Teams.Hiders
if (seekerAlive == false) then -- Hider Victory, Seeker dead.
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Hiders)
GAMEMODE.RoundManager:SetState(StatePostRound)
else
if (GAMEMODE.Data.RoundTime <= 0) then -- No Time remaining
GAMEMODE:SetRoundWinner(GAMEMODE.Teams.Hiders)
GAMEMODE.RoundManager:SetState(StatePostRound)
end
end
end
end
@@ -72,7 +72,6 @@ function GM:CreateTeams()
team.SetUp(self.Teams.Spectators, "Spectators", Color(127, 127, 127, 255))
team.SetSpawnPoint(self.Teams.Spectators, {
"info_player_deathmatch",
"info_player_axis",
"info_player_combine",
"info_player_counterterrorist",
"info_player_allies",
@@ -85,7 +84,6 @@ function GM:CreateTeams()
team.SetSpawnPoint(self.Teams.Seekers, {
"info_player_spawn",
"info_player_deathmatch",
"info_player_axis",
"info_player_combine",
"info_player_counterterrorist"
})
@@ -127,4 +125,12 @@ end
-- ------------------------------------------------------------------------- --
function GM:GetRoundState()
return GetGlobalInt("RoundState", self.States.PreMatch)
end
function GM:GetRoundTime()
return GetGlobalInt("RoundTime", 0)
end
function GM:GetRoundWinner()
return GetGlobalInt("RoundWinner", GAMEMODE.Teams.Spectator)
end