From 81d068a2bd81801e7c4aa48c65b2000b1f308618 Mon Sep 17 00:00:00 2001 From: ampreeT <61920833+ampreeT@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:46:15 -0700 Subject: [PATCH] Hide tracers of vehicles & turrets --- .../include/srccoop/blackmesa/deathnotice.inc | 8 +++--- .../include/srccoop/blackmesa/entitypatch.inc | 26 ++++++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/scripting/include/srccoop/blackmesa/deathnotice.inc b/scripting/include/srccoop/blackmesa/deathnotice.inc index 469933b8..fad17982 100644 --- a/scripting/include/srccoop/blackmesa/deathnotice.inc +++ b/scripting/include/srccoop/blackmesa/deathnotice.inc @@ -9,14 +9,14 @@ char g_pDnDisplayList[][2][] = { // NPCS. - { "npc_abrams", "Tank" }, + { "npc_abrams", "HECU Abrams" }, { "npc_alien_controller", "Alien Controller" }, { "npc_alien_grunt", "Alien Grunt" }, { "npc_alien_grunt_elite", "Elite Alien Grunt" }, { "npc_alien_grunt_melee", "Alien Grunt" }, { "npc_alien_slave", "Alien Slave" }, { "npc_alien_slave_dummy", "Alien Slave" }, - { "npc_apache", "Apache" }, + { "npc_apache", "HECU Apache" }, { "npc_barnacle", "Barnacle" }, { "npc_beneathticle", "Underwater Barnacle" }, { "npc_boid", "Boid" }, @@ -49,7 +49,7 @@ char g_pDnDisplayList[][2][] = { "npc_human_security", "Security Guard" }, { "npc_ichthyosaur", "Ichthyosaur" }, { "npc_kleiner", "Dr. Kliener" }, - { "npc_lav", "LAV" }, + { "npc_lav", "HECU LAV" }, { "npc_leech", "Leech" }, { "npc_nihilanth", "Nihilanth" }, { "npc_osprey", "Osprey" }, @@ -62,7 +62,7 @@ char g_pDnDisplayList[][2][] = { "npc_sentry_ceiling", "Turret" }, { "npc_sentry_ground", "Turret" }, { "npc_snark", "Snark" }, - { "npc_sniper", "Marine Sniper" }, + { "npc_sniper", "HECU Sniper" }, { "npc_tentacle", "Alien Tentacle" }, { "npc_vortigaunt", "Alien Slave" }, { "npc_xen_grunt", "Alien Grunt" }, diff --git a/scripting/include/srccoop/blackmesa/entitypatch.inc b/scripting/include/srccoop/blackmesa/entitypatch.inc index d77b2803..b06d4690 100644 --- a/scripting/include/srccoop/blackmesa/entitypatch.inc +++ b/scripting/include/srccoop/blackmesa/entitypatch.inc @@ -232,16 +232,34 @@ public MRESReturn Hook_PropChargerThinkPost(int _this) //------------------------------------------------------ // TE - BlackMesa Shot -// Fix npc_sniper tracers hard crashing some client configurations +// Fix npc_sniper tracers hard crashing some client configurations and +// hides the tracers of certain npcs due to incorrect firing position //------------------------------------------------------ public Action BlackMesaFireBulletsTEHook(const char[] szTEName, const int[] iClients, int iNumClients, float flDelay) { + // Prevent crashes from `npc_sniper` on certain client configurations. int iAmmoId = TE_ReadNum("m_iAmmoID"); if (iAmmoId == AMMO_SNIPERROUND) - { - TE_WriteNum("m_bDoTracers", 0); return Plugin_Changed; - } + + // TE will crash all clients without a valid entity. + CBaseEntity pEntity = CBaseEntity(TE_ReadNum("m_iEntityIndex")); + if (pEntity == NULL_CBASEENTITY) + return Plugin_Changed; + + char szClassname[MAX_CLASSNAME]; + if (!pEntity.GetClassname(szClassname, sizeof(szClassname))) + return Plugin_Changed; + + // Hide tracers of broken npcs. + // TODO: + // Instead of hiding the tracers, they should be displayed correctly. + if (strcmp(szClassname, "npc_sentry_ground") == 0 || + strcmp(szClassname, "npc_sentry_ceiling") == 0 || + strcmp(szClassname, "npc_abrams") == 0 || + strcmp(szClassname, "npc_lav") == 0) + return Plugin_Changed; + return Plugin_Continue; }