From 6c8d785ce263111dd47c5eb79701788a922a754e Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Thu, 22 Dec 2022 13:02:30 -0800 Subject: [PATCH] env_shooter: Respect rendering modes, also add support for the 'shootsounds' key. snark_pit will be more complete now. --- base/src/server/client.qc | 32 ------------- src/gs-entbase/server/env_shooter.qc | 70 ++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 35 deletions(-) diff --git a/base/src/server/client.qc b/base/src/server/client.qc index 7496a963..322ea70e 100644 --- a/base/src/server/client.qc +++ b/base/src/server/client.qc @@ -22,43 +22,11 @@ Game_RunClientCommand(void) pl.Physics_Run(); } -/* custom chat packet */ -void -SV_SendChat(entity sender, string msg, entity eEnt, float fType) -{ - WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); - WriteByte(MSG_MULTICAST, fType == 0 ? EV_CHAT:EV_CHAT_TEAM); - WriteByte(MSG_MULTICAST, num_for_edict(sender) - 1); - WriteByte(MSG_MULTICAST, sender.team); - WriteString(MSG_MULTICAST, msg); - if (eEnt) { - msg_entity = eEnt; - multicast([0,0,0], MULTICAST_ONE); - } else { - multicast([0,0,0], MULTICAST_ALL); - } - - localcmd(sprintf("echo [SERVER] %s: %s\n", sender.netname, msg)); -} - /* client cmd overrides happen here */ void Game_ParseClientCommand(string cmd) { tokenize(cmd); - if (argv(0) == "say") { - SV_SendChat(self, argv(1), world, 0); - return; - } else if (argv(0) == "say_team") { - entity a; - for (a = world; (a = find(a, ::classname, "player"));) { - if (a.team == self.team) { - SV_SendChat(self, argv(1), a, 1); - } - } - return; - } - clientcommand(self, cmd); } diff --git a/src/gs-entbase/server/env_shooter.qc b/src/gs-entbase/server/env_shooter.qc index be4b3103..f983d309 100644 --- a/src/gs-entbase/server/env_shooter.qc +++ b/src/gs-entbase/server/env_shooter.qc @@ -38,7 +38,7 @@ Shoots model entities from its location. This entity was introduced in Half-Life (1998). */ class -env_shooter:NSPointTrigger +env_shooter:NSRenderableEntity { int m_iGibs; int m_iGibsLeft; @@ -55,6 +55,7 @@ env_shooter:NSPointTrigger public: void env_shooter(void); + virtual void Spawned(void); virtual void Save(float); virtual void Restore(string,string); virtual void SpawnKey(string,string); @@ -79,6 +80,38 @@ env_shooter::env_shooter(void) m_flSkin = 0; } +void +env_shooter::Spawned(void) +{ + super::Spawned(); + + if (m_strShootModel) + precache_model(m_strShootModel); + + /* There isn't a much more portable to do this, maybe this can be abstracted + through separate soundDef entries but I don't know if that'll be less annoying. */ + switch (m_flShootSounds) { + case 0: /* glass */ + Sound_Precache("func_breakable.impact_glass"); + break; + case 1: /* wood */ + Sound_Precache("func_breakable.impact_wood"); + break; + case 2: /* metal */ + Sound_Precache("func_breakable.impact_metal"); + break; + case 3: /* flesh */ + Sound_Precache("func_breakable.impact_flesh"); + break; + case 4: /* concrete */ + Sound_Precache("func_breakable.impact_concrete"); + break; + case -1: /* none */ + default: + break; + } +} + void env_shooter::Save(float handle) { @@ -138,6 +171,9 @@ void env_shooter::SpawnKey(string strKey, string strValue) { switch (strKey) { + case "angle": + angles = [stof(strValue) * 90, 0, 0]; + break; case "m_iGibs": m_iGibs = stoi(strValue); break; @@ -155,7 +191,6 @@ env_shooter::SpawnKey(string strKey, string strValue) break; case "shootmodel": m_strShootModel = strValue; - precache_model(m_strShootModel); break; case "shootsounds": m_flShootSounds = stof(strValue); @@ -194,10 +229,39 @@ env_shooter::ShootGib(void) eGib.SetModel(m_strShootModel); eGib.SetOrigin(GetOrigin()); eGib.SetAngles(GetAngles()); + eGib.SetRenderColor(m_vecRenderColor); + eGib.SetRenderMode(m_iRenderMode); + eGib.SetRenderFX(m_iRenderFX); + eGib.SetRenderAmt(m_flRenderAmt); + eGib.SetScale(m_flScale); + + switch (m_flShootSounds) { + case 0: /* glass */ + StartSoundDef("func_breakable.impact_glass", CHAN_VOICE, false); + break; + case 1: /* wood */ + StartSoundDef("func_breakable.impact_wood", CHAN_VOICE, false); + break; + case 2: /* metal */ + StartSoundDef("func_breakable.impact_metal", CHAN_VOICE, false); + break; + case 3: /* flesh */ + StartSoundDef("func_breakable.impact_flesh", CHAN_VOICE, false); + break; + case 4: /* concrete */ + StartSoundDef("func_breakable.impact_concrete", CHAN_VOICE, false); + break; + case -1: /* none */ + default: + break; + } + + if (m_flGibLife <= 0) + m_flGibLife = 1.0f; makevectors(GetAngles()); vecThrowVel = v_forward * m_flVelocity; - vecThrowVel += [0.0f, 0.0f, 64.0f + (random() * 64.0f)]; + vecThrowVel += [0.0f, 0.0f, 32.0f + (random() * 32.0f)]; vecSpinVel[0] = random(-1,1) * 32; vecSpinVel[1] = random(-1,1) * 32; vecSpinVel[2] = random(-1,1) * 32;