2019-08-31 19:18:15 -07:00
|
|
|
/*
|
2022-07-07 09:10:14 -07:00
|
|
|
* Copyright (c) 2016-2022 Vera Visions LLC.
|
2019-08-31 19:18:15 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2022-07-07 09:10:14 -07:00
|
|
|
*/
|
2019-03-13 13:56:43 -07:00
|
|
|
|
2019-12-22 03:13:49 -08:00
|
|
|
/* this is causing crashes on OpenAL 1.19.1 when enabled */
|
|
|
|
//#define DSP_LERP
|
|
|
|
|
2022-12-07 12:48:34 -08:00
|
|
|
static string g_hlefx[] = {
|
2021-04-22 02:33:48 -07:00
|
|
|
"default",
|
|
|
|
"gs_generic",
|
|
|
|
"gs_metal_s",
|
|
|
|
"gs_metal_m",
|
|
|
|
"gs_metal_l",
|
|
|
|
"gs_tunnel_s",
|
|
|
|
"gs_tunnel_m",
|
|
|
|
"gs_tunnel_l",
|
|
|
|
"gs_chamber_s",
|
|
|
|
"gs_chamber_m",
|
|
|
|
"gs_chamber_l",
|
|
|
|
"gs_bright_s",
|
|
|
|
"gs_bright_m",
|
|
|
|
"gs_bright_l",
|
|
|
|
"gs_water1",
|
|
|
|
"gs_water2",
|
|
|
|
"gs_water3",
|
|
|
|
"gs_concrete_s",
|
|
|
|
"gs_concrete_m",
|
|
|
|
"gs_concrete_l",
|
|
|
|
"gs_big1",
|
|
|
|
"gs_big2",
|
|
|
|
"gs_big3",
|
|
|
|
"gs_cavern_s",
|
|
|
|
"gs_cavern_m",
|
|
|
|
"gs_cavern_l",
|
|
|
|
"gs_weirdo1",
|
|
|
|
"gs_weirdo2",
|
|
|
|
"gs_weirdo3"
|
2019-03-13 13:56:43 -07:00
|
|
|
};
|
|
|
|
|
2023-03-13 01:29:18 -07:00
|
|
|
/*!QUAKED env_sound (1 .5 0) (-8 -8 -8) (8 8 8)
|
2022-12-13 17:52:20 -08:00
|
|
|
# OVERVIEW
|
|
|
|
Client-side environmental reverb modifier.
|
|
|
|
|
|
|
|
# KEYS
|
|
|
|
- "radius" : Radius in units.
|
|
|
|
- "efx_file" : Name of the OpenAL EFX definiton to use.
|
|
|
|
- "roomtype" : Legacy enumeration for GoldSrc support. Please don't use this.
|
|
|
|
|
|
|
|
# NOTES
|
|
|
|
This works only with the OpenAL sound backend.
|
|
|
|
|
|
|
|
# TRIVIA
|
|
|
|
This entity was introduced in Half-Life (1998).
|
|
|
|
*/
|
2021-10-19 16:18:36 -07:00
|
|
|
class env_sound:NSEntity
|
2019-03-19 12:01:24 -07:00
|
|
|
{
|
2022-12-06 15:04:07 -08:00
|
|
|
public:
|
|
|
|
void env_sound(void);
|
|
|
|
|
|
|
|
virtual void Respawn(void);
|
|
|
|
virtual void SpawnKey(string,string);
|
2023-01-06 13:23:48 -08:00
|
|
|
virtual bool CanSpawn(bool);
|
2022-12-06 15:04:07 -08:00
|
|
|
|
|
|
|
private:
|
2019-03-13 13:56:43 -07:00
|
|
|
int m_iRoomType;
|
|
|
|
int m_iRadius;
|
|
|
|
};
|
|
|
|
|
2023-01-06 13:23:48 -08:00
|
|
|
bool
|
|
|
|
env_sound::CanSpawn(bool clientSide)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-23 11:13:27 -07:00
|
|
|
void
|
|
|
|
env_sound::SpawnKey(string strField, string strKey)
|
2019-03-13 13:56:43 -07:00
|
|
|
{
|
|
|
|
switch (strField) {
|
2021-04-22 02:33:48 -07:00
|
|
|
case "efx_file":
|
|
|
|
m_iRoomType = EFX_Load(strKey);
|
2019-03-13 13:56:43 -07:00
|
|
|
break;
|
|
|
|
case "radius":
|
|
|
|
m_iRadius = stoi(strKey);
|
|
|
|
break;
|
2021-04-22 02:33:48 -07:00
|
|
|
/* GoldSrc, legacy */
|
|
|
|
case "roomtype":
|
|
|
|
int efx_alias = stoi(strKey);
|
2021-04-22 02:44:53 -07:00
|
|
|
|
|
|
|
if (efx_alias >= g_hlefx.length) {
|
2024-03-02 00:40:08 -08:00
|
|
|
EntWarning("invalid roomtype!");
|
2021-04-22 02:44:53 -07:00
|
|
|
m_iRoomType = 0;
|
|
|
|
} else
|
|
|
|
m_iRoomType = EFX_Load(g_hlefx[efx_alias]);
|
2021-04-22 02:33:48 -07:00
|
|
|
break;
|
2019-03-13 13:56:43 -07:00
|
|
|
default:
|
2021-10-19 16:18:36 -07:00
|
|
|
super::SpawnKey(strField, strKey);
|
2019-03-13 13:56:43 -07:00
|
|
|
}
|
|
|
|
}
|
2021-10-19 16:18:36 -07:00
|
|
|
|
2022-06-01 17:38:52 -07:00
|
|
|
void
|
|
|
|
env_sound::Respawn(void)
|
|
|
|
{
|
|
|
|
SetSize([0,0,0], [0,0,0]);
|
|
|
|
SetOrigin(GetSpawnOrigin());
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:18:36 -07:00
|
|
|
void
|
|
|
|
env_sound::env_sound(void)
|
|
|
|
{
|
|
|
|
m_iRadius = 256;
|
2022-06-03 15:22:33 -07:00
|
|
|
isCSQC = true;
|
2021-10-19 16:18:36 -07:00
|
|
|
}
|