2019-08-31 19:18:15 -07:00
|
|
|
/*
|
2020-04-07 05:46:23 -07:00
|
|
|
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
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.
|
|
|
|
*/
|
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
|
|
|
|
|
2020-03-23 23:26:49 -07:00
|
|
|
/*QUAKED env_sound (0 1 0.5) (-8 -8 -8) (8 8 8)
|
2021-07-14 02:49:30 -07:00
|
|
|
Client-side environmental reverb modifier.
|
|
|
|
|
|
|
|
-------- KEYS --------
|
2021-07-17 12:04:34 -07:00
|
|
|
"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.
|
2019-09-06 20:37:06 -07:00
|
|
|
|
2021-07-14 02:49:30 -07:00
|
|
|
-------- NOTES --------
|
2019-09-06 20:37:06 -07:00
|
|
|
This works only with the OpenAL sound backend.
|
2020-10-25 04:38:41 -07:00
|
|
|
|
2021-07-14 02:49:30 -07:00
|
|
|
-------- TRIVIA --------
|
2020-10-25 04:38:41 -07:00
|
|
|
This entity was introduced in Half-Life (1998).
|
2019-09-06 20:37:06 -07:00
|
|
|
*/
|
|
|
|
|
2021-04-22 02:33:48 -07:00
|
|
|
string g_hlefx[] = {
|
|
|
|
"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
|
|
|
};
|
|
|
|
|
2019-03-19 12:01:24 -07:00
|
|
|
class env_sound:CBaseEntity
|
|
|
|
{
|
2019-03-13 13:56:43 -07:00
|
|
|
int m_iRoomType;
|
|
|
|
int m_iRadius;
|
|
|
|
|
2020-04-12 06:50:42 -07:00
|
|
|
void(void) env_sound;
|
2019-03-13 13:56:43 -07:00
|
|
|
virtual void(string, string) SpawnKey;
|
|
|
|
};
|
|
|
|
|
2020-10-23 11:13:27 -07:00
|
|
|
void
|
|
|
|
env_sound::env_sound(void)
|
2019-03-13 13:56:43 -07:00
|
|
|
{
|
2019-11-08 17:09:17 -08:00
|
|
|
m_iRadius = 256;
|
|
|
|
Init();
|
2019-03-13 13:56:43 -07:00
|
|
|
|
2021-04-20 10:54:11 -07:00
|
|
|
setsize(this, [0,0,0], [0,0,0]);
|
2019-11-08 17:09:17 -08:00
|
|
|
setorigin(this, origin);
|
2019-03-13 13:56:43 -07:00
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
print("^1env_sound::SpawnKey: Invalid roomtype!\n");
|
|
|
|
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:
|
|
|
|
CBaseEntity::SpawnKey(strField, strKey);
|
|
|
|
}
|
|
|
|
}
|