Rounds work, rounds ending, domination flags get contested

This commit is contained in:
Fesiug 2024-09-16 16:57:20 -04:00
parent 85f9d855db
commit 1286e17447
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
4 changed files with 56 additions and 30 deletions

View File

@ -35,6 +35,7 @@ function ENT:SetupDataTables()
self:NetworkVar( "Float", "CapturePercent" )
self:NetworkVar( "Int", "TeamTaking" )
self:NetworkVar( "Int", "TeamOwned" )
self:NetworkVar( "Bool", "Contested" )
end
function ENT:Think()
@ -56,6 +57,8 @@ function ENT:Think()
end
end
self:SetContested( Contested )
local BlockPoints = false
local RoundActive = BennyGame:GetState() == BG_STATE_ACTIVE

View File

@ -23,6 +23,10 @@ function BennyGame:GetMode()
return cGamemode:GetString()
end
function BennyGame:GetModeData()
return BennyGame.Gamemodes[ BennyGame:GetMode() ]
end
BennyGame.TeamsInPlay = {
4,
3,
@ -39,49 +43,51 @@ BennyGame.Gamemodes = {
description = "#Gamemode.tdm.Description",
scorelimit = CreateConVar("b-g_tdm_scorelimit", 75 ),
timelimit = CreateConVar("b-g_tdm_timelimit", 10 ),
timelimit = CreateConVar("b-g_tdm_timelimit", 10*60 ),
},
["ffa"] = {
name = "#Gamemode.ffa.Name",
description = "#Gamemode.ffa.Description",
scorelimit = CreateConVar("b-g_ffa_scorelimit", 30 ),
timelimit = CreateConVar("b-g_ffa_timelimit", 10 ),
timelimit = CreateConVar("b-g_ffa_timelimit", 10*60 ),
},
["snd"] = {
name = "#Gamemode.snd.Name",
description = "#Gamemode.snd.Description",
scorelimit = CreateConVar("b-g_snd_scorelimit", 6 ),
timelimit = CreateConVar("b-g_snd_timelimit", 2.5 ),
timelimit = CreateConVar("b-g_snd_timelimit", 2.5*60 ),
},
["ctf"] = {
name = "#Gamemode.ctf.Name",
description = "#Gamemode.ctf.Description",
scorelimit = CreateConVar("b-g_ctf_scorelimit", 3 ),
timelimit = CreateConVar("b-g_ctf_timelimit", 10 ),
timelimit = CreateConVar("b-g_ctf_timelimit", 10*60 ),
},
["dom"] = {
name = "#Gamemode.dom.Name",
description = "#Gamemode.dom.Description",
scorelimit = CreateConVar("b-g_dom_scorelimit", 1000 ),
timelimit = CreateConVar("b-g_dom_timelimit", 10 ),
timelimit = CreateConVar("b-g_dom_timelimit", 10*60 ),
roundlimit = CreateConVar("b-g_dom_roundlimit", 1 ),
},
["dem"] = {
name = "#Gamemode.dem.Name",
description = "#Gamemode.dem.Description",
scorelimit = CreateConVar("b-g_dem_scorelimit", 3 ),
timelimit = CreateConVar("b-g_dem_timelimit", 5 ),
timelimit = CreateConVar("b-g_dem_timelimit", 5*60 ),
roundlimit = CreateConVar("b-g_dom_roundlimit", 2 ),
},
["hp"] = {
name = "#Gamemode.hp.Name",
description = "#Gamemode.hp.Description",
scorelimit = CreateConVar("b-g_hp_scorelimit", 300 ),
timelimit = CreateConVar("b-g_hp_timelimit", 10 ),
timelimit = CreateConVar("b-g_hp_timelimit", 10*60 ),
},
}
@ -171,6 +177,11 @@ function BennyGame:GetTimeLimit()
return BennyGame.Gamemodes[BennyGame:GetMode()].timelimit:GetInt() + BennyGame:GetTimeExtension()
end
function BennyGame:GetRoundLimit()
if !BennyGame.Gamemodes[BennyGame:GetMode()].roundlimit then return false end
return BennyGame.Gamemodes[BennyGame:GetMode()].roundlimit:GetInt()
end
function BennyGame:GetPregameTime()
return cPregame:GetInt()
@ -205,15 +216,16 @@ end
BG_ER_TIMELIMIT = 0
BG_ER_SCORELIMIT = 1
BG_ER_NUKE = 2
BG_ER_FORCE = 3
function BennyGame:StartRound()
PrintMessage(HUD_PRINTCENTER, "Round start!")
BennyGame:SetState( BG_STATE_ACTIVE )
BennyGame:SetRoundStartedAt( CurTime() )
--game.CleanUpMap()
--for _, ply in player.Iterator() do
-- ply:Spawn()
--end
game.CleanUpMap()
for _, ply in player.Iterator() do
ply:Spawn()
end
end
function BennyGame:EndRound( reason, forceteam )
@ -303,6 +315,12 @@ end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
concommand.Add("b-cheat_endround", function( ply, cmd, args )
BennyGame:EndRound( args[1] or BG_ER_FORCE, args[2] )
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
hook.Add("Think", "Benny_Gamestate_Think", function()
if SERVER then
local World = Entity(0)
@ -340,6 +358,9 @@ hook.Add("Think", "Benny_Gamestate_Think", function()
if BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime() <= CurTime() then
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
BennyGame:SetScoreForTeam( RealTeamID, 0 )
end
BennyGame:SetState( BG_STATE_WAITINGFORPLAYERS )
end

View File

@ -644,7 +644,9 @@ function GM:HUDPaint()
local TITLE = "CAPTURING"
local PERCENT = obj:GetCapturePercent()
if obj:GetTeamOwned() == myteam then
if obj:GetContested() then
TITLE = "CONTESTED"
elseif obj:GetTeamOwned() == myteam then
if obj:GetCapturePercent() > 0 then
TITLE = "CLEARING"
else
@ -655,15 +657,18 @@ function GM:HUDPaint()
TITLE = "CLEARING"
end
local BARCOLOR_MAIN = TEAMS[obj:GetTeamOwned()].factionid
BARCOLOR_MAIN = FACTIONS[BARCOLOR_MAIN].COLOR_MAIN
local BARCOLOR_DARK = TEAMS[obj:GetTeamOwned()].factionid
BARCOLOR_DARK = FACTIONS[BARCOLOR_DARK].COLOR_DARK
local BARCOLOR = FACTIONS[ TEAMS[obj:GetTeamOwned()].factionid ]
local TAKCOLOR = FACTIONS[ TEAMS[obj:GetTeamTaking()].factionid ]
local CONTOLER = FACTIONS[ "unassigned" ]
local TAKCOLOR_MAIN = TEAMS[obj:GetTeamTaking()].factionid
TAKCOLOR_MAIN = FACTIONS[TAKCOLOR_MAIN].COLOR_MAIN
local TAKCOLOR_DARK = TEAMS[obj:GetTeamTaking()].factionid
TAKCOLOR_DARK = FACTIONS[TAKCOLOR_DARK].COLOR_DARK
BARCOLOR_MAIN = BARCOLOR.COLOR_MAIN
BARCOLOR_DARK = BARCOLOR.COLOR_DARK
TAKCOLOR_MAIN = TAKCOLOR.COLOR_MAIN
TAKCOLOR_DARK = TAKCOLOR.COLOR_DARK
CONTOLER_MAIN = CONTOLER.COLOR_MAIN
CONTOLER_DARK = CONTOLER.COLOR_DARK
local BWIDE, BTALL = 180, 16
@ -680,19 +685,19 @@ function GM:HUDPaint()
local x, y = hXY( 0, TITLE=="SECURE" and 62 or 40 )
qt( TITLE, "HUD_24", x, y, COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
qt( TITLE, "HUD_24", x, y, obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
if TITLE!="SECURE" then
S_Push( -BWIDE/2, 62 )
hCol( COLOR_DARK )
hCol( obj:GetContested() and CONTOLER_DARK or COLOR_DARK )
hRect( 0, 0, 180, BTALL )
hCol( COLOR_MAIN )
hCol( obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN )
hORect( 1, 1, 180-2, BTALL-2 )
hCol( TITLE=="CLEARING" and TAKCOLOR_MAIN or COLOR_MAIN )
hCol( obj:GetContested() and CONTOLER_MAIN or TITLE=="CLEARING" and TAKCOLOR_MAIN or COLOR_MAIN )
hRect( 3, 3, math.floor((BWIDE-6) * PERCENT), BTALL-6 )
S_Pop()
local x, y = hXY( 0, 78 )
qt( math.floor(PERCENT*100) .. "%", "HUD_36", x, y, COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
qt( math.floor(PERCENT*100) .. "%", "HUD_36", x, y, obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN, TEXT_ALIGN_CENTER, nil, obj:GetContested() and CONTOLER_DARK or COLOR_DARK )
end
S_Pop()
end

View File

@ -120,10 +120,8 @@ function GM:CreateTeams()
end
function GM:PlayerSelectTeamSpawn( TeamID, ply )
print( TeamID )
local SpawnPoints = team.GetSpawnPoints( TeamID )
PrintTable( SpawnPoints )
if ( !SpawnPoints || table.IsEmpty( SpawnPoints ) ) then print("fail")return end
if ( !SpawnPoints || table.IsEmpty( SpawnPoints ) ) then return end
local ChosenSpawnPoint = nil
@ -142,8 +140,7 @@ function GM:PlayerSelectSpawn( ply, transition )
if BennyGame:GetType() == BG_GTYPE_MP then
local ent = self:PlayerSelectTeamSpawn( ply:Team(), ply )
debug.Trace()
if IsValid( ent ) then print("win") return ent end
if IsValid( ent ) then return ent end
end
end