Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
all.qc File Reference
#include "all.qh"
#include <server/utils.qh>
Include dependency graph for all.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void play2 (entity e, string filename)
void play2all (string samp)
void play2team (float t, string filename)
int precache_sound_index (string s)
 hack: string precache_sound(string s) = #19;
bool sound_allowed (int to, entity e)
void soundat (entity e, vector o, int chan, string samp, float vol, float _atten)
void soundto (int _dest, entity e, int chan, string samp, float vol, float _atten, float _pitch)
void soundtoat (int to, entity e, vector o, int chan, string samp, float vol, float attenu, float _pitch)
float spamsound (entity e, int chan, Sound samp, float vol, float _atten)
 use this one if you might be causing spam (e.g.
void stopsound (entity e, int chan)
void stopsoundto (int _dest, entity e, int chan)

Variables

bool autocvar_bot_sound_monopoly
entity realowner
const int SND_ATTENUATION = BIT(1)
const int SND_LARGEENTITY = BIT(3)
const int SND_LARGESOUND = BIT(4)
const int SND_SPEEDUSHORT4000 = BIT(5)
const int SND_VOLUME = BIT(0)
float spamtime
const int SVC_SOUND = 6
const int SVC_STOPSOUND = 16

Function Documentation

◆ play2()

void play2 ( entity e,
string filename )

Definition at line 116 of file all.qc.

117{
118 msg_entity = e;
119 soundtoat(MSG_ONE, NULL, '0 0 0', CH_INFO, filename, VOL_BASE, ATTEN_NONE, 0);
120}
float MSG_ONE
Definition menudefs.qc:56
#define NULL
Definition post.qh:14
entity msg_entity
Definition progsdefs.qc:63
const float VOL_BASE
Definition sound.qh:36
const int CH_INFO
Definition sound.qh:6
const float ATTEN_NONE
Definition sound.qh:27
void soundtoat(int to, entity e, vector o, int chan, string samp, float vol, float attenu, float _pitch)
Definition all.qc:39

References ATTEN_NONE, CH_INFO, entity(), msg_entity, MSG_ONE, NULL, soundtoat(), and VOL_BASE.

Referenced by client_hasweapon(), door_check_keys(), door_touch(), fragsfilter_use(), item_key_touch(), nades_GiveBonus(), ons_CaptureShield_Touch(), ons_ControlPoint_Icon_Damage(), ons_GeneratorDamage(), play2team(), secret_touch(), SUB_UseTargets_Ex(), target_print_message(), target_voicescript_next(), trigger_keylock_touch(), vehicles_locktarget(), W_MineLayer_Attack(), and W_Reload().

◆ play2all()

void play2all ( string samp)

Definition at line 142 of file all.qc.

143{
144 if (autocvar_bot_sound_monopoly) return;
146}
#define _sound(e, c, s, v, a)
Definition sound.qh:43
bool autocvar_bot_sound_monopoly
Definition all.qc:6

References _sound, ATTEN_NONE, autocvar_bot_sound_monopoly, CH_INFO, NULL, and VOL_BASE.

Referenced by dompoint_captured(), kh_LoserTeam(), kh_WinnerTeam(), and Onslaught_CheckWinner().

◆ play2team()

void play2team ( float t,
string filename )

Definition at line 136 of file all.qc.

137{
138 if (autocvar_bot_sound_monopoly) return;
139 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.team == t, play2(it, filename));
140}
#define IS_PLAYER(s)
Definition player.qh:243
void play2(entity e, string filename)
Definition all.qc:116
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References autocvar_bot_sound_monopoly, FOREACH_CLIENT, IS_PLAYER, IS_REAL_CLIENT, and play2().

Referenced by ons_ControlPoint_Icon_Damage(), and ons_GeneratorDamage().

◆ precache_sound_index()

int precache_sound_index ( string s)

hack: string precache_sound(string s) = #19;

Referenced by soundtoat(), and stopsoundto().

◆ sound_allowed()

bool sound_allowed ( int to,
entity e )

Definition at line 9 of file all.qc.

10{
11 if(!e) return true; // save on a few checks
12 for ( ; ; )
13 {
14 if (e.classname == "body") e = e.enemy;
15 else if (e.realowner && e.realowner != e) e = e.realowner;
16 else if (e.owner && e.owner != e) e = e.owner;
17 else break;
18 }
19 // sounds to self may always pass
20 if (to == MSG_ONE && e == msg_entity) return true;
21 // sounds by players can be removed
22 if (autocvar_bot_sound_monopoly && IS_REAL_CLIENT(e)) return false;
23 // anything else may pass
24 return true;
25}

References autocvar_bot_sound_monopoly, entity(), IS_REAL_CLIENT, msg_entity, and MSG_ONE.

Referenced by _GlobalSound(), CSQCProjectile(), Damage_DamageInfo(), globalsound(), GrapplingHookSend(), Monster_Damage(), PlayerCorpseDamage(), PlayerDamage(), playersound(), soundto(), soundtoat(), spamsound(), SpawnCasing(), stopsound(), stopsoundto(), vehicles_damage(), Violence_GibSplash_At(), and W_Tuba_NoteSendEntity().

◆ soundat()

void soundat ( entity e,
vector o,
int chan,
string samp,
float vol,
float _atten )

Definition at line 80 of file all.qc.

81{
82 soundtoat(((chan & 8) ? MSG_ALL : MSG_BROADCAST), e, o, chan, samp, vol, _atten, 0);
83}
float MSG_BROADCAST
Definition menudefs.qc:55
float MSG_ALL
Definition menudefs.qc:57

References entity(), MSG_ALL, MSG_BROADCAST, soundtoat(), and vector.

◆ soundto()

void soundto ( int _dest,
entity e,
int chan,
string samp,
float vol,
float _atten,
float _pitch )

Definition at line 74 of file all.qc.

75{
76 if (!sound_allowed(_dest, e)) return;
77 vector o = e.origin + 0.5 * (e.mins + e.maxs);
78 soundtoat(_dest, e, o, chan, samp, vol, _atten, _pitch);
79}
vector
Definition self.qh:92
bool sound_allowed(int to, entity e)
Definition all.qc:9

References entity(), sound_allowed(), soundtoat(), and vector.

Referenced by _GlobalSound(), func_breakable_init_for_player(), func_rotating_init_for_player(), func_vectormamamam_init_for_player(), globalsound(), Item_RespawnCountdown(), ons_GeneratorThink(), playersound(), raptor_frame(), spawnfunc(), spawnfunc(), spawnfunc(), and target_speaker_use_activator().

◆ soundtoat()

void soundtoat ( int to,
entity e,
vector o,
int chan,
string samp,
float vol,
float attenu,
float _pitch )

Definition at line 39 of file all.qc.

40{
41 if (!sound_allowed(to, e)) return;
42 int entno = etof(e);
43 int idx = precache_sound_index(samp);
44 attenu = floor(attenu * 64);
45 vol = floor(vol * 255);
46 int sflags = 0;
47 int speed4000 = floor((_pitch * 0.01) * 4000 + 0.5);
48 if (vol != 255) sflags |= SND_VOLUME;
49 if (attenu != 64) sflags |= SND_ATTENUATION;
50 if (entno >= 8192 || chan < 0 || chan > 7) sflags |= SND_LARGEENTITY;
51 if (idx >= 256) sflags |= SND_LARGESOUND;
52 if (speed4000 && speed4000 != 4000) sflags |= SND_SPEEDUSHORT4000;
54 WriteByte(to, sflags);
55 if (sflags & SND_VOLUME) WriteByte(to, vol);
56 if (sflags & SND_ATTENUATION) WriteByte(to, attenu);
57 if (sflags & SND_SPEEDUSHORT4000) WriteShort(to, speed4000);
58 if (sflags & SND_LARGEENTITY)
59 {
60 WriteShort(to, entno);
61 WriteByte(to, chan);
62 }
63 else
64 {
65 WriteShort(to, (entno << 3) | chan);
66 }
67 if (sflags & SND_LARGESOUND) WriteShort(to, idx);
68 else WriteByte(to, idx);
69 WriteCoord(to, o.x);
70 WriteCoord(to, o.y);
71 WriteCoord(to, o.z);
72}
void WriteShort(float data, float dest, float desto)
void WriteCoord(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
float floor(float f)
#define etof(e)
Definition misc.qh:25
const int SND_VOLUME
Definition all.qc:33
const int SND_ATTENUATION
Definition all.qc:34
const int SND_SPEEDUSHORT4000
Definition all.qc:37
const int SVC_SOUND
Definition all.qc:30
const int SND_LARGEENTITY
Definition all.qc:35
int precache_sound_index(string s)
hack: string precache_sound(string s) = #19;
const int SND_LARGESOUND
Definition all.qc:36

References entity(), etof, floor(), precache_sound_index(), SND_ATTENUATION, SND_LARGEENTITY, SND_LARGESOUND, SND_SPEEDUSHORT4000, SND_VOLUME, sound_allowed(), SVC_SOUND, vector, WriteByte(), WriteCoord(), and WriteShort().

Referenced by FireRailgunBullet(), play2(), soundat(), and soundto().

◆ spamsound()

float spamsound ( entity e,
int chan,
Sound samp,
float vol,
float _atten )

use this one if you might be causing spam (e.g.

from touch functions that might get called more than once per frame)

Definition at line 124 of file all.qc.

125{
126 if (!sound_allowed(MSG_BROADCAST, e)) return false;
127 if (time > e.spamtime)
128 {
129 e.spamtime = time;
130 sound(e, chan, samp, vol, _atten);
131 return true;
132 }
133 return false;
134}
float time
#define sound(e, c, s, v, a)
Definition sound.qh:52

References entity(), MSG_BROADCAST, sound, sound_allowed(), and time.

Referenced by Monster_Damage(), nade_napalm_ball(), nade_touch(), vehicles_damage(), W_Electro_Orb_Touch(), W_MineLayer_Stick(), W_MineLayer_Think(), W_Mortar_Grenade_Touch1(), W_Mortar_Grenade_Touch2(), and W_Porto_Touch().

◆ stopsound()

void stopsound ( entity e,
int chan )

Definition at line 109 of file all.qc.

110{
111 if (!sound_allowed(MSG_BROADCAST, e)) return;
112 stopsoundto(MSG_BROADCAST, e, chan); // unreliable, gets there fast
113 stopsoundto(MSG_ALL, e, chan); // in case of packet loss
114}
void stopsoundto(int _dest, entity e, int chan)
Definition all.qc:84

References entity(), MSG_ALL, MSG_BROADCAST, sound_allowed(), and stopsoundto().

Referenced by func_breakable_behave_destroyed(), func_rotating_setactive(), func_vectormamamam_setactive(), player_powerups_remove_all(), and PutPlayerInServer().

◆ stopsoundto()

void stopsoundto ( int _dest,
entity e,
int chan )

Definition at line 84 of file all.qc.

85{
86 if (!sound_allowed(_dest, e)) return;
87 int entno = etof(e);
88 if (entno >= 8192 || chan < 0 || chan > 7)
89 {
90 int idx = precache_sound_index(SND(Null));
91 int sflags = SND_LARGEENTITY;
92 if (idx >= 256) sflags |= SND_LARGESOUND;
93 WriteByte(_dest, SVC_SOUND);
94 WriteByte(_dest, sflags);
95 WriteShort(_dest, entno);
96 WriteByte(_dest, chan);
97 if (sflags & SND_LARGESOUND) WriteShort(_dest, idx);
98 else WriteByte(_dest, idx);
99 WriteCoord(_dest, e.origin.x);
100 WriteCoord(_dest, e.origin.y);
101 WriteCoord(_dest, e.origin.z);
102 }
103 else
104 {
105 WriteByte(_dest, SVC_STOPSOUND);
106 WriteShort(_dest, entno * 8 + chan);
107 }
108}
const int SVC_STOPSOUND
Definition all.qc:31
#define SND(id)
Definition all.qh:35

References entity(), etof, precache_sound_index(), SND, SND_LARGEENTITY, SND_LARGESOUND, sound_allowed(), SVC_SOUND, SVC_STOPSOUND, WriteByte(), WriteCoord(), and WriteShort().

Referenced by stopsound(), and train_wait().

Variable Documentation

◆ autocvar_bot_sound_monopoly

bool autocvar_bot_sound_monopoly

Definition at line 6 of file all.qc.

Referenced by play2all(), play2team(), and sound_allowed().

◆ realowner

entity realowner

Definition at line 8 of file all.qc.

◆ SND_ATTENUATION

const int SND_ATTENUATION = BIT(1)

Definition at line 34 of file all.qc.

Referenced by soundtoat().

◆ SND_LARGEENTITY

const int SND_LARGEENTITY = BIT(3)

Definition at line 35 of file all.qc.

Referenced by soundtoat(), and stopsoundto().

◆ SND_LARGESOUND

const int SND_LARGESOUND = BIT(4)

Definition at line 36 of file all.qc.

Referenced by soundtoat(), and stopsoundto().

◆ SND_SPEEDUSHORT4000

const int SND_SPEEDUSHORT4000 = BIT(5)

Definition at line 37 of file all.qc.

Referenced by soundtoat().

◆ SND_VOLUME

const int SND_VOLUME = BIT(0)

Definition at line 33 of file all.qc.

Referenced by soundtoat().

◆ spamtime

float spamtime

Definition at line 122 of file all.qc.

◆ SVC_SOUND

const int SVC_SOUND = 6

Definition at line 30 of file all.qc.

Referenced by soundtoat(), and stopsoundto().

◆ SVC_STOPSOUND

const int SVC_STOPSOUND = 16

Definition at line 31 of file all.qc.

Referenced by stopsoundto().