Skip to content

Commit

Permalink
Merge pull request #12 from fluffy-servers/gamemode-prototypes
Browse files Browse the repository at this point in the history
Gamemode prototypes: 1.3 Update
  • Loading branch information
Robert Fraser authored Apr 27, 2019
2 parents c54c181 + 4d1aa40 commit b5fbaf7
Show file tree
Hide file tree
Showing 33 changed files with 1,715 additions and 175 deletions.
5 changes: 4 additions & 1 deletion fluffy_climb/gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ DeriveGamemode('fluffy_mg_base')
GM.Name = 'Climb!'
GM.Author = 'FluffyXVI'
GM.HelpText = [[
todo help text
Race to the top in this fast-paced climbing gamemode!
Platforms are randomly generated. Be careful not to fall!
Bright green platforms will launch you into the air.
]]

GM.TeamBased = false -- Is the gamemode FFA or Teams?
Expand Down
Binary file not shown.
66 changes: 47 additions & 19 deletions fluffy_mg_base/gamemode/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,88 @@ include('vgui/Screen_Maps.lua')
include('vgui/Screen_Scoreboard.lua')

-- Register universal fonts
surface.CreateFont( "FS_16", {
-- Coolvetica
surface.CreateFont("FS_16", {
font = "Coolvetica",
size = 20,
} )
surface.CreateFont( "FS_24", {
})
surface.CreateFont("FS_24", {
font = "Coolvetica",
size = 24,
} )
surface.CreateFont( "FS_32", {
})
surface.CreateFont("FS_32", {
font = "Coolvetica",
size = 32,
} )
surface.CreateFont( "FS_40", {
})
surface.CreateFont("FS_40", {
font = "Coolvetica",
size = 40,
} )
surface.CreateFont( "FS_60", {
})
surface.CreateFont("FS_60", {
font = "Coolvetica",
size = 48, -- hmmm
} )
surface.CreateFont( "FS_64", {
})
surface.CreateFont("FS_64", {
font = "Coolvetica",
size = 64,
} )
surface.CreateFont( "FS_128", {
})
surface.CreateFont("FS_128", {
font = "Coolvetica",
size = 128,
} )
})

surface.CreateFont( "FS_B24", {
-- Bebas Kai
surface.CreateFont("FS_B24", {
font = "Bebas Kai",
size = 24,
})

surface.CreateFont( "FS_B32", {
surface.CreateFont("FS_B32", {
font = "Bebas Kai",
size = 32,
})

surface.CreateFont( "FS_B40", {
surface.CreateFont("FS_B40", {
font = "Bebas Kai",
size = 40,
})

surface.CreateFont( "FS_B64", {
surface.CreateFont("FS_B64", {
font = "Bebas Kai",
size = 64,
})

surface.CreateFont( "FS_B96", {
surface.CreateFont("FS_B96", {
font = "Bebas Kai",
size = 128,
})

-- Lemon/Milk
surface.CreateFont("FS_L24", {
font = "Lemon/Milk",
size = 24,
})

surface.CreateFont("FS_L32", {
font = "Lemon/Milk",
size = 32,
})

surface.CreateFont("FS_L40", {
font = "Lemon/Milk",
size = 40,
})

surface.CreateFont("FS_L48", {
font = "Lemon/Milk",
size = 48,
})

surface.CreateFont("FS_L64", {
font = "Lemon/Milk",
size = 64,
})

-- Font for CSS Kill Icons
-- Needed for some weapons
surface.CreateFont( "CSKillIcons", {
Expand Down
130 changes: 129 additions & 1 deletion fluffy_mg_base/gamemode/cl_playerpanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--]]

-- Information & help panel at the start of a game
--[[
function GM:CreateHelpPanel()
if IsValid(GAMEMODE.MinigamesHelpPanel) then return end
Expand All @@ -13,7 +14,7 @@ function GM:CreateHelpPanel()
function f:Paint(w, h)
draw.RoundedBox(0, 0, 0, w, 64, GAMEMODE.FCol2)
draw.RoundedBox(0, 0, 64, w, h-64, Color(150, 150, 160))--Color(53, 59, 72))
draw.SimpleText(GAMEMODE.Name, 'FS_B64', 4, 0, GAMEMODE.FCol1)
draw.SimpleText(GAMEMODE.Name, 'FS_L64', 4, 0, GAMEMODE.FCol1)
end
f:MakePopup()
Expand Down Expand Up @@ -82,6 +83,133 @@ function GM:CreateHelpPanel()
GAMEMODE.MinigamesHelpPanel = f
end
--]]

local motd_lightblue = Color(0, 168, 255)
local motd_darkblue = Color(0, 151, 230)
local motd_white = Color(245, 246, 250)
function GM:CreateHelpPanel()
if IsValid(GAMEMODE.MinigamesHelpPanel) then return end

-- Create the frame
local f = vgui.Create('DFrame')
f:SetTitle('')
f:SetSize(ScrW()*0.75, ScrH()*0.75)
f:Center()
f:MakePopup()
f:ShowCloseButton(false)
f.CreationTime = CurTime()

-- Draw the frame
f.Paint = function(self, w, h)
Derma_DrawBackgroundBlur(self, self.CreationTime)
DisableClipping(true)
draw.RoundedBox(8, 0, 8, w, h, motd_darkblue)
draw.RoundedBox(8, 0, 0, w, h, motd_lightblue)
draw.RoundedBox(0, 0, 64, w, h-112, motd_white)

draw.SimpleText('Fluffy Servers', 'FS_L24', 10, 8, motd_white)
draw.SimpleText(GAMEMODE.Name, 'FS_L40', 8, 24, motd_white)
DisableClipping(false)
end

-- Create a discord button because I'm a sucker for advertising
if true then
local discord = vgui.Create('HTML', f)
discord:SetSize(192, 64)
discord:SetPos(f:GetWide()-192-4, 0)
discord:OpenURL('https://www.fluffyservers.com/discord_ad.html')

local discord_button = vgui.Create('DButton', discord)
discord_button:Dock(FILL)
discord_button:SetDrawBackground(false)
discord_button:SetDrawBorder(false)
discord_button:SetCursor('hand')
discord_button:SetText('')
discord_button.DoClick = function(self, w, h)
gui.OpenURL('https://discord.gg/rMy4nH5')
end
end

local motd_html = vgui.Create('DHTML', f)
motd_html:SetSize(f:GetWide(), f:GetTall() - 112)
motd_html:SetPos(0, 64)
motd_html:OpenURL('https://www.fluffyservers.com/guide/minigames.html')
motd_html:Call('UpdateGamemodeName("' .. GAMEMODE.Name .. '")')
motd_html:Call('UpdateGamemodeDesc("' .. string.Replace(GAMEMODE.HelpText, '\n', '</p><p>') .. '")')

-- Buttons!
local play_button = vgui.Create('DButton', f)
play_button:SetSize(128, 48)
play_button:SetPos(f:GetWide() - 128, f:GetTall() - 48)
play_button.Paint = function(self, w, h)
DisableClipping(true)
draw.RoundedBoxEx(8, 0, 8, w, h, Color(68, 189, 50), false, false, false, true)
draw.RoundedBoxEx(8, 0, 0, w, h, Color(76, 209, 55), false, false, false, true)
draw.SimpleText(self.Message or 'Play!', 'FS_32', w/2, h/2 + 2, motd_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
DisableClipping(false)
end
play_button:SetText('')
play_button.DoClick = function()
f:Close()
end

-- Add team buttons (if applicable)
if GAMEMODE.TeamBased and not GAMEMODE.TeamSurvival then
local tw = 160
local xx = tw
if LocalPlayer():Team() == TEAM_CONNECTING or LocalPlayer():Team() == TEAM_UNASSIGNED then
play_button:Remove()
else
play_button.Message = 'Close'
xx = xx + 128
end
for id, t in pairs(team.GetAllTeams()) do
if id == TEAM_CONNECTING or id == TEAM_UNASSIGNED then continue end

local teamp = vgui.Create('DButton', f)
teamp:SetSize(tw, 48)
teamp:SetPos(f:GetWide() - xx, f:GetTall()-48)
if xx <= tw then
teamp.Corner = true
end
teamp:SetText('')
teamp:SetTextColor(GAMEMODE.FCol1)
teamp:SetFont('FS_B40')
local c = team.GetColor(id)
if id == TEAM_SPECTATOR then
c = Color(225, 177, 44)
end

function teamp:Paint(w, h)
DisableClipping(true)
local c_shadow = Color(c.r - 10, c.g-10, c.b-10)
if self.Corner then
draw.RoundedBoxEx(8, 0, 8, w, h, c_shadow, false, false, false, true)
draw.RoundedBoxEx(8, 0, 0, w, h, c, false, false, false, true)
else
draw.RoundedBox(0, 0, 8, w, h, c_shadow)
draw.RoundedBox(0, 0, 0, w, h, c)
end

local name = team.GetName(id) or ''
draw.SimpleText(name, 'FS_32', w/2, h/2 - 6, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
local num = team.NumPlayers(id) or 0
draw.SimpleText(num .. ' players', 'FS_16', w/2, h/2 + 14, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
DisableClipping(false)
end

function teamp:DoClick()
f:Close()
RunConsoleCommand('changeteam', id)
end

xx = xx + tw
end
end

GAMEMODE.MinigamesHelpPanel = f
end

-- Bind the above panel to a concommand
concommand.Add('minigames_info', function()
Expand Down
4 changes: 2 additions & 2 deletions fluffy_mg_base/gamemode/gametype_hunter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ end )

-- Stop Hunters from switching back to the other team
hook.Add('PlayerCanJoinTeam', 'StopHunterSwap', function(ply, team)
print(ply)
print('trying to change team')
if not GAMEMODE.TeamSurvival then return end

local current_team = ply:Team()
if current_team == GAMEMODE.HunterTeam then
ply:ChatPrint('You cannot change teams currently')
Expand Down
14 changes: 6 additions & 8 deletions fluffy_mg_base/gamemode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ AddCSLuaFile('sh_levels.lua')

-- Add workshop content
resource.AddWorkshop('1518438705')
resource.AddFile('resource/fonts/BebasKai.ttf')
resource.AddFile('resource/fonts/LemonMilk.ttf')

-- Include useful server files
include('shared.lua')
Expand Down Expand Up @@ -134,9 +136,10 @@ function GM:PlayerRequestTeam(ply, teamid)
end

-- Disable friendly fire
function GM:PlayerShouldTakeDamage( victim, ply )
function GM:PlayerShouldTakeDamage(victim, ply)
if !GAMEMODE.TeamBased then return true end
if !ply:IsPlayer() then return true end
if ply == victim then return true end
if ply:Team() == victim:Team() then return false end
return true
end
Expand Down Expand Up @@ -331,16 +334,11 @@ function GM:HandlePlayerDeath(ply, attacker, dmginfo)
GAMEMODE:AddStatPoints(attacker, 'kills', 1)

if GAMEMODE.TeamBased then
if !GAMEMODE.TeamKills then
GAMEMODE.TeamKills = {}
GAMEMODE.TeamKills[1] = 0
GAMEMODE.TeamKills[2] = 0
end

-- Add the kill to the team
local team = attacker:Team()
if team == TEAM_SPECTATOR or team == TEAM_UNASSIGNED then return end
GAMEMODE.TeamKills[team] = GAMEMODE.TeamKills[team] + 1
local team_kills_current = GetGlobalInt(team .. 'TeamKills')
SetGlobalInt(team .. 'TeamKills', team_kills_current + 1)
else
if not attacker.FFAKills then attacker.FFAKills = 0 end
attacker.FFAKills = attacker.FFAKills + 1
Expand Down
2 changes: 2 additions & 0 deletions fluffy_mg_base/gamemode/shop/cl_inventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function SHOP:PopulateSettings()
end

function SHOP:OpenInventory()
if true then return end -- disable this function for now

if IsValid(SHOP.InventoryPanel) then return end
SHOP:VerifyInventory()

Expand Down
10 changes: 4 additions & 6 deletions fluffy_mg_base/gamemode/sv_round.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function GM:PreStartRound()

-- Probably bugged
if GAMEMODE.TeamBased then
GAMEMODE.TeamKills = nil
SetGlobalInt('1TeamKills', 0)
SetGlobalInt('2TeamKills', 0)
end

-- Set global round data
Expand Down Expand Up @@ -233,13 +234,10 @@ function GM:HandleTeamWin(reason)
if GAMEMODE.TeamSurvival then
winners = GAMEMODE.SurvivorTeam
msg = team.GetName(GAMEMODE.SurvivorTeam) .. ' win the round!'
elseif !GAMEMODE.TeamKills then
winners = 0
msg = 'Draw! Nobody wins.'
elseif GAMEMODE.TeamKills[1] > GAMEMODE.TeamKills[2] then
elseif GetGlobalInt('1TeamKills', 0) > GetGlobalInt('2TeamKills', 0) then
winners = 1
msg = team.GetName(1) .. ' win the round!'
elseif GAMEMODE.TeamKills[2] < GAMEMODE.TeamKills[1] then
elseif GetGlobalInt('1TeamKills', 0) < GetGlobalInt('2TeamKills', 0) then
winners = 2
msg = team.GetName(2) .. ' win the round!'
else
Expand Down
Loading

0 comments on commit b5fbaf7

Please sign in to comment.