From e0f5124cce0eb1bbc047cf189d8d676e405555a1 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 28 Nov 2020 13:58:51 +0100 Subject: [PATCH] func_button: Add remaining Outputs: OnDamaged, OnIn, OnOut, OnUseLocked --- src/gs-entbase/server/basetrigger.cpp | 3 ++ src/gs-entbase/server/func_button.cpp | 53 ++++++++++++++++--- .../shared/info_particle_system.cpp | 5 ++ src/gs-entbase/shared/light_dynamic.cpp | 23 ++++---- src/shared/sound.c | 3 ++ 5 files changed, 68 insertions(+), 19 deletions(-) diff --git a/src/gs-entbase/server/basetrigger.cpp b/src/gs-entbase/server/basetrigger.cpp index 5110b7e2..94807048 100644 --- a/src/gs-entbase/server/basetrigger.cpp +++ b/src/gs-entbase/server/basetrigger.cpp @@ -18,6 +18,9 @@ void CBaseTrigger::UseOutput(entity act, string outname) { + if (!outname) + return; + for (entity f = world; (f = find(f, ::targetname, outname));) { CBaseOutput op = (CBaseOutput)f; diff --git a/src/gs-entbase/server/func_button.cpp b/src/gs-entbase/server/func_button.cpp index bcb98de0..d33bb0bd 100644 --- a/src/gs-entbase/server/func_button.cpp +++ b/src/gs-entbase/server/func_button.cpp @@ -27,6 +27,13 @@ "sounds" Obsolete legacy key for HL/Q1 style buttons to decide which sounds to play. +Outputs: +"OnDamaged" Fired when the button is damaged. +"OnPressed" Fired when the button is pressed. +"OnUseLocked" Fired when the button is used while locked. +"OnIn" Fired when the button reaches the in/pressed position. +"OnOut" Fired when the button reaches the out/released position. + A brush entity which can be used either by touching, interaction (via a games' use-key/button or other targetting methods. It will then travel, similar to a door to a specified direction. @@ -96,6 +103,10 @@ class func_button:CBaseTrigger /* input/output */ string m_strOnPressed; + string m_strOnDamaged; + string m_strOnUseLocked; + string m_strOnIn; + string m_strOnOut; virtual void(void) Respawn; virtual void(void) Arrived; @@ -120,6 +131,7 @@ func_button::Arrived(void) velocity = [0,0,0]; nextthink = 0; + UseOutput(this, m_strOnIn); m_iState = STATE_RAISED; if (spawnflags & SF_BTT_TOUCH_ONLY) { @@ -141,6 +153,7 @@ func_button::Arrived(void) void func_button::Returned(void) { + UseOutput(this, m_strOnOut); SetOrigin(m_vecDest); velocity = [0,0,0]; nextthink = 0; @@ -200,6 +213,9 @@ func_button::MoveAway(void) void func_button::Trigger(entity act, int state) { + + UseOutput(act, m_strOnUseLocked); + if (m_flNextTrigger > time) { return; } @@ -245,7 +261,11 @@ func_button::Use(void) void func_button::Death(void) { - Trigger(g_dmg_eAttacker, TRIG_TOGGLE); + if (m_strOnOut) + UseOutput(g_dmg_eAttacker, m_strOnDamaged); + else + Trigger(g_dmg_eAttacker, TRIG_TOGGLE); + health = m_oldHealth; } @@ -378,6 +398,22 @@ func_button::SpawnKey(string strKey, string strValue) strValue = strreplace(",", ",_", strValue); m_strOnPressed = strcat(m_strOnPressed, ",_", strValue); break; + case "OnDamaged": + strValue = strreplace(",", ",_", strValue); + m_strOnDamaged = strcat(m_strOnDamaged, ",_", strValue); + break; + case "OnUseLocked": + strValue = strreplace(",", ",_", strValue); + m_strOnUseLocked = strcat(m_strOnUseLocked, ",_", strValue); + break; + case "OnIn": + strValue = strreplace(",", ",_", strValue); + m_strOnIn = strcat(m_strOnIn, ",_", strValue); + break; + case "OnOut": + strValue = strreplace(",", ",_", strValue); + m_strOnOut = strcat(m_strOnOut, ",_", strValue); + break; /* compatibility */ case "sounds": m_strSndPressed = sprintf("func_button.hlsfx_%i", stoi(strValue) + 1i); @@ -394,13 +430,14 @@ func_button::func_button(void) CBaseTrigger::CBaseTrigger(); - if (m_strSndPressed) - Sound_Precache(m_strSndPressed); - - if (m_strSndUnpressed) - Sound_Precache(m_strSndUnpressed); + /* sounds */ + Sound_Precache(m_strSndPressed); + Sound_Precache(m_strSndUnpressed); /* input/output */ - if (m_strOnPressed) - m_strOnPressed = CreateOutput(m_strOnPressed); + m_strOnPressed = CreateOutput(m_strOnPressed); + m_strOnDamaged = CreateOutput(m_strOnDamaged); + m_strOnUseLocked = CreateOutput(m_strOnUseLocked); + m_strOnIn = CreateOutput(m_strOnIn); + m_strOnOut = CreateOutput(m_strOnOut); } diff --git a/src/gs-entbase/shared/info_particle_system.cpp b/src/gs-entbase/shared/info_particle_system.cpp index 81d440e9..ab87f6a0 100644 --- a/src/gs-entbase/shared/info_particle_system.cpp +++ b/src/gs-entbase/shared/info_particle_system.cpp @@ -21,6 +21,11 @@ "interval" Override for spawn intervals. "spawncount" Override for the amount of particles that will be emitted +Inputs: +"Start" Starts the emitter. +"Stop" Stops the emitter. +"Toggle" Toggles the emitter from an on/off state. + An entity that's spawns particles from the engine's particle system. Trivia: diff --git a/src/gs-entbase/shared/light_dynamic.cpp b/src/gs-entbase/shared/light_dynamic.cpp index 82e3b1db..7c064471 100644 --- a/src/gs-entbase/shared/light_dynamic.cpp +++ b/src/gs-entbase/shared/light_dynamic.cpp @@ -26,6 +26,18 @@ "style" Select one of the hard-coded lightstyles. "start_active" Override for if the entity should start on or off. +Inputs: +"TurnOn" Turns the light on. +"TurnOff" Turns the light off. +"Toggle" Toggles the light from an on/off state. +"Color" Sets the light color in RGB255 format. +"brightness" Sets the light brightness. +"distance" Sets the distance of which the light will travel/radius. +"_inner_cone" Sets the length of the inner light cone. +"_cone" Sets the length of the light cone. +"spotlight_radius" Sets the radius of the projected spotlight. +"style" Sets the light appearance in integer form. + Dynamic light entity. Can be parented to things, it even has some inputs that may be interesting. @@ -306,17 +318,6 @@ light_dynamic::Respawn(void) SetAngles(m_oldAngle); m_iState = (m_iStartActive == 1) ? 1 : 0; - - SendFlags = DLIGHTFL_CHANGED_ORIGIN | \ - DLIGHTFL_CHANGED_ANGLES | \ - DLIGHTFL_CHANGED_LIGHT | \ - DLIGHTFL_CHANGED_INTENSITY | \ - DLIGHTFL_CHANGED_INNERCONE | \ - DLIGHTFL_CHANGED_CONE | \ - DLIGHTFL_CHANGED_DISTANCE | \ - DLIGHTFL_CHANGED_RADIUS | \ - DLIGHTFL_CHANGED_STYLE | \ - DLIGHTFL_CHANGED_STATE; } #endif diff --git a/src/shared/sound.c b/src/shared/sound.c index 761d7951..fd652357 100644 --- a/src/shared/sound.c +++ b/src/shared/sound.c @@ -210,6 +210,9 @@ Sound_Precache(string shader) string line; int index; + if (!shader) + return -1; + index = g_sounds_count; shader = strtolower(shader);