Skip to content

Commit

Permalink
Various: Add ShouldDrawCosmetics hooks
Browse files Browse the repository at this point in the history
Appropiate hook additions to the following gamemodes:
 - Staker
 - Poltergeist
 - Suicide Barrels
 - Laser Dance
  • Loading branch information
FluffyXVI committed May 17, 2019
1 parent 48579d9 commit 045c5e0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
8 changes: 7 additions & 1 deletion fluffy_laserdance/gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ GM.SpawnProtection = true

function GM:Initialize()

end
end

-- Hide all Tracer and Trail cosmetics
-- Part of the Laser Dance mechanics is the bright lasers everywhere
hook.Add('ShouldDrawCosmetics', 'HideLaserDanceCosmetics', function(ply, ITEM)
if ITEM.Type == 'Tracer' or ITEM.Type == 'Trail' then return false end
end)
2 changes: 1 addition & 1 deletion fluffy_mg_base/gamemode/shop/cl_render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function SHOP:RenderCosmetics(ent, ply, force)
if not SHOP.ClientModels[ply] then return end

for _, ITEM in pairs(SHOP.ClientModels[ply]) do
if not GAMEMODE:ShouldDrawCosmetics(ply, ITEM) and not force then continue end
if not GAMEMODE:DoCosmeticsCheck(ply, ITEM) and not force then continue end
if not ITEM.ent then continue end

-- Search for the attachment and calculate the position & angles
Expand Down
4 changes: 2 additions & 2 deletions fluffy_mg_base/gamemode/shop/sh_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ end
-- Add the cosmetics check hook function
-- This function is hooked into various gamemodes to stop cosmetics from being drawn when they shouldn't be
-- Key examples of this is to override tracers, hide hats on certain playermodels, etc.
function GM:ShouldDrawCosmetics(ply, ITEM)
return hook.Run('DrawCosmeticsCheck', ply, ITEM) or true
function GM:DoCosmeticsCheck(ply, ITEM)
return hook.Run('ShouldDrawCosmetics', ply, ITEM) or true
end

SHOP:LoadResources()
Expand Down
4 changes: 2 additions & 2 deletions fluffy_mg_base/gamemode/shop/sv_equip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end
function SHOP:WearTrail(ply, force)
if ply.EquippedTrail then
local ITEM = ply.EquippedTrail
if not GAMEMODE:ShouldDrawCosmetics(ply, ITEM) and not force then return end
if not GAMEMODE:DoCosmeticsCheck(ply, ITEM) and not force then return end
ply.TrailEntity = util.SpriteTrail(ply, 0, ITEM.Color or color_white, false, 20, 2, 2.5, 0.1, ITEM.Material)
end
end
Expand Down Expand Up @@ -75,7 +75,7 @@ hook.Add('EntityFireBullets', 'ShopTracerEffects', function(ent, data)
local effect = ent:GetNWString('ShopTracerEffect')
if not effect then return end

if not GAMEMODE:ShouldDrawCosmetics(ent, {Type='Tracer'}) then return end
if not GAMEMODE:DoCosmeticsCheck(ent, {Type='Tracer'}) then return end

data.Tracer = 1
data.TracerName = effect
Expand Down
7 changes: 6 additions & 1 deletion fluffy_poltergeist/gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ function GM:CreateTeams()

team.SetUp( TEAM_SPECTATOR, "Spectators", Color( 255, 255, 80 ), true )
team.SetSpawnPoint( TEAM_SPECTATOR, { "info_player_start", "info_player_terrorist", "info_player_combine" } )
end
end

-- Hide all cosmetics on Poltergeists
hook.Add('ShouldDrawCosmetics', 'HideHunterCosmetics', function(ply, ITEM)
if ply:Team() == TEAM_RED then return false end
end)
8 changes: 7 additions & 1 deletion fluffy_stalker/gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ function GM:CreateTeams()

team.SetUp(TEAM_SPECTATOR, "Spectators", Color( 255, 255, 80 ), true)
team.SetSpawnPoint(TEAM_SPECTATOR, { "info_player_start", "info_player_terrorist", "info_player_combine" })
end
end

-- Hide all cosmetics for the Stalker
-- It'd be a bit sucky for the invisible man to have a very obvious top hat equipped
hook.Add('ShouldDrawCosmetics', 'HideHunterCosmetics', function(ply, ITEM)
if ply:Team() == TEAM_RED then return false end
end)
7 changes: 6 additions & 1 deletion fluffy_suicidebarrels/gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ end

function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
if ply:Team() == TEAM_RED then return true end
end
end

-- Hide all cosmetics for barrels
hook.Add('ShouldDrawCosmetics', 'HideHunterCosmetics', function(ply, ITEM)
if ply:Team() == TEAM_RED then return false end
end)

0 comments on commit 045c5e0

Please sign in to comment.