5 const int CH_TRIGGER = -3;
6 const int CH_WEAPON_A = -1;
7 const int CH_WEAPON_SINGLE = 1;
8 const int CH_VOICE = -2;
9 const int CH_BGM_SINGLE = 8;
10 const int CH_AMBIENT = -9;
11 const int CH_TRIGGER_SINGLE = 3;
12 const int CH_SHOTS = -4;
13 const int CH_SHOTS_SINGLE = 4;
14 const int CH_WEAPON_B = -1;
15 const int CH_PAIN = -6;
16 const int CH_PAIN_SINGLE = 6;
17 const int CH_PLAYER = -7;
18 const int CH_PLAYER_SINGLE = 7;
19 const int CH_TUBA_SINGLE = 5;
21 const float ATTEN_NONE = 0;
22 const float ATTEN_MIN = 0.015625;
23 const float ATTEN_NORM = 0.5;
24 const float ATTEN_LARGE = 1;
25 const float ATTEN_IDLE = 2;
26 const float ATTEN_STATIC = 3;
27 const float ATTEN_MAX = 3.984375;
29 const float VOL_BASE = 0.7;
30 const float VOL_BASEVOICE = 1.0;
32 // Play all sounds via sound7, for access to the extra channels.
33 // Otherwise, channels 8 to 15 would be blocked for a weird QW feature.
35 #define _sound(e, c, s, v, a) \
39 if (!sound_allowed(MSG_BROADCAST, __e)) break; \
40 sound7(__e, c, s, v, a, 0, 0); \
44 #define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0)
46 #define sound(e, c, s, v, a) _sound(e, c, Sound_fixpath(s), v, a)
49 * because sound7 didn't have origin
51 * @param e sound owner
52 * @param o sound origin
53 * @param chan sound channel
54 * @param samp sound filename
55 * @param vol sound volume
56 * @param atten sound attenuation
60 #define sound8(e, o, chan, samp, vol, atten, speed, sf) \
64 vector old_origin = __e.origin; \
65 vector old_mins = __e.mins; \
66 vector old_maxs = __e.maxs; \
68 setsize(__e, '0 0 0', '0 0 0'); \
69 sound7(__e, chan, samp, vol, atten, speed, sf); \
70 setorigin(__e, old_origin); \
71 setsize(__e, old_mins, old_maxs); \
76 ATTRIB(Sound, m_id, int, 0)
77 ATTRIB(Sound, sound_str, string(), func_null)
78 CONSTRUCTOR(Sound, string() path)
81 this.sound_str = path;
83 #define Sound_fixpath(this) _Sound_fixpath((this).sound_str())
84 string _Sound_fixpath(string base)
86 if (base == "") return string_null;
87 #define extensions(x) \
92 string full, relative;
93 #define tryext(ext) { if (fexists(full = strcat("sound/", relative = strcat(base, "." #ext)))) break; }
99 LOG_WARNINGF("Missing sound: \"%s\"\n", full);
105 METHOD(Sound, sound_precache, void(entity this))
107 string s = Sound_fixpath(this);
109 LOG_TRACEF("precache_sound(\"%s\")\n", s);