From 045c5e0bbf351c11f8eed4b84cbd9411ecea9e68 Mon Sep 17 00:00:00 2001 From: FluffyXVI Date: Fri, 17 May 2019 11:56:59 +1000 Subject: [PATCH] Various: Add ShouldDrawCosmetics hooks Appropiate hook additions to the following gamemodes: - Staker - Poltergeist - Suicide Barrels - Laser Dance --- fluffy_laserdance/gamemode/shared.lua | 8 +++++++- fluffy_mg_base/gamemode/shop/cl_render.lua | 2 +- fluffy_mg_base/gamemode/shop/sh_init.lua | 4 ++-- fluffy_mg_base/gamemode/shop/sv_equip.lua | 4 ++-- fluffy_poltergeist/gamemode/shared.lua | 7 ++++++- fluffy_stalker/gamemode/shared.lua | 8 +++++++- fluffy_suicidebarrels/gamemode/shared.lua | 7 ++++++- 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/fluffy_laserdance/gamemode/shared.lua b/fluffy_laserdance/gamemode/shared.lua index 46e25ca..031d4fe 100644 --- a/fluffy_laserdance/gamemode/shared.lua +++ b/fluffy_laserdance/gamemode/shared.lua @@ -24,4 +24,10 @@ GM.SpawnProtection = true function GM:Initialize() -end \ No newline at end of file +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) \ No newline at end of file diff --git a/fluffy_mg_base/gamemode/shop/cl_render.lua b/fluffy_mg_base/gamemode/shop/cl_render.lua index b28afad..df59472 100644 --- a/fluffy_mg_base/gamemode/shop/cl_render.lua +++ b/fluffy_mg_base/gamemode/shop/cl_render.lua @@ -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 diff --git a/fluffy_mg_base/gamemode/shop/sh_init.lua b/fluffy_mg_base/gamemode/shop/sh_init.lua index 2120367..3fea86e 100644 --- a/fluffy_mg_base/gamemode/shop/sh_init.lua +++ b/fluffy_mg_base/gamemode/shop/sh_init.lua @@ -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() diff --git a/fluffy_mg_base/gamemode/shop/sv_equip.lua b/fluffy_mg_base/gamemode/shop/sv_equip.lua index 438feb0..24655a9 100644 --- a/fluffy_mg_base/gamemode/shop/sv_equip.lua +++ b/fluffy_mg_base/gamemode/shop/sv_equip.lua @@ -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 @@ -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 diff --git a/fluffy_poltergeist/gamemode/shared.lua b/fluffy_poltergeist/gamemode/shared.lua index 8f64a5b..4cef8d3 100644 --- a/fluffy_poltergeist/gamemode/shared.lua +++ b/fluffy_poltergeist/gamemode/shared.lua @@ -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 \ No newline at end of file +end + +-- Hide all cosmetics on Poltergeists +hook.Add('ShouldDrawCosmetics', 'HideHunterCosmetics', function(ply, ITEM) + if ply:Team() == TEAM_RED then return false end +end) \ No newline at end of file diff --git a/fluffy_stalker/gamemode/shared.lua b/fluffy_stalker/gamemode/shared.lua index 59458bc..dad0175 100644 --- a/fluffy_stalker/gamemode/shared.lua +++ b/fluffy_stalker/gamemode/shared.lua @@ -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 \ No newline at end of file +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) \ No newline at end of file diff --git a/fluffy_suicidebarrels/gamemode/shared.lua b/fluffy_suicidebarrels/gamemode/shared.lua index 6106fc6..d2230d7 100644 --- a/fluffy_suicidebarrels/gamemode/shared.lua +++ b/fluffy_suicidebarrels/gamemode/shared.lua @@ -54,4 +54,9 @@ end function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf ) if ply:Team() == TEAM_RED then return true end -end \ No newline at end of file +end + +-- Hide all cosmetics for barrels +hook.Add('ShouldDrawCosmetics', 'HideHunterCosmetics', function(ply, ITEM) + if ply:Team() == TEAM_RED then return false end +end) \ No newline at end of file