Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
tuba.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Tuba

Macros

#define X(BEGIN, P, END, class, prefix)

Functions

 classfield (Tuba) .int note
 entityclass (Tuba)
 MODEL (ACCORDION_VIEW, W_Model("h_akordeon.iqm"))
 MODEL (ACCORDION_WORLD, W_Model("v_akordeon.md3"))
 MODEL (KLEINBOTTLE_VIEW, W_Model("h_kleinbottle.iqm"))
 MODEL (KLEINBOTTLE_WORLD, W_Model("v_kleinbottle.md3"))
 MODEL (TUBA_ITEM, W_Model("g_tuba.md3"))
 MODEL (TUBA_VIEW, W_Model("h_tuba.iqm"))
 MODEL (TUBA_WORLD, W_Model("v_tuba.md3"))
 REGISTER_WEAPON (TUBA, NEW(Tuba))
bool W_Tuba_HasPlayed (entity pl,.entity weaponentity, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)

Variables

float autocvar_cl_tuba_attenuation = 0.5
float autocvar_cl_tuba_fadetime = 0.25
float autocvar_cl_tuba_pitchstep = 6
float autocvar_cl_tuba_volume = 1
float autocvar_snd_soundradius

Macro Definition Documentation

◆ X

#define X ( BEGIN,
P,
END,
class,
prefix )
Value:
BEGIN(class) \
P(class, prefix, animtime, float, NONE) \
P(class, prefix, attenuation, float, NONE) \
P(class, prefix, damage, float, NONE) \
P(class, prefix, edgedamage, float, NONE) \
P(class, prefix, force, float, NONE) \
P(class, prefix, radius, float, NONE) \
P(class, prefix, refire, float, NONE) \
P(class, prefix, switchdelay_drop, float, NONE) \
P(class, prefix, switchdelay_raise, float, NONE) \
P(class, prefix, weaponreplace, string, NONE) \
P(class, prefix, weaponstartoverride, float, NONE) \
P(class, prefix, weaponstart, float, NONE) \
P(class, prefix, weaponthrowable, float, NONE) \
END()
float radius
Definition impulse.qh:11

Definition at line 37 of file tuba.qh.

37#define X(BEGIN, P, END, class, prefix) \
38 BEGIN(class) \
39 P(class, prefix, animtime, float, NONE) \
40 P(class, prefix, attenuation, float, NONE) \
41 P(class, prefix, damage, float, NONE) \
42 P(class, prefix, edgedamage, float, NONE) \
43 P(class, prefix, force, float, NONE) \
44 P(class, prefix, radius, float, NONE) \
45 P(class, prefix, refire, float, NONE) \
46 P(class, prefix, switchdelay_drop, float, NONE) \
47 P(class, prefix, switchdelay_raise, float, NONE) \
48 P(class, prefix, weaponreplace, string, NONE) \
49 P(class, prefix, weaponstartoverride, float, NONE) \
50 P(class, prefix, weaponstart, float, NONE) \
51 P(class, prefix, weaponthrowable, float, NONE) \
52 END()

Function Documentation

◆ classfield()

classfield ( Tuba )

References tuba_instrument.

◆ entityclass()

entityclass ( Tuba )

◆ MODEL() [1/7]

MODEL ( ACCORDION_VIEW ,
W_Model("h_akordeon.iqm")  )

◆ MODEL() [2/7]

MODEL ( ACCORDION_WORLD ,
W_Model("v_akordeon.md3")  )

◆ MODEL() [3/7]

MODEL ( KLEINBOTTLE_VIEW ,
W_Model("h_kleinbottle.iqm")  )

◆ MODEL() [4/7]

MODEL ( KLEINBOTTLE_WORLD ,
W_Model("v_kleinbottle.md3")  )

◆ MODEL() [5/7]

MODEL ( TUBA_ITEM ,
W_Model("g_tuba.md3")  )

◆ MODEL() [6/7]

MODEL ( TUBA_VIEW ,
W_Model("h_tuba.iqm")  )

◆ MODEL() [7/7]

MODEL ( TUBA_WORLD ,
W_Model("v_tuba.md3")  )

◆ REGISTER_WEAPON()

REGISTER_WEAPON ( TUBA ,
NEW(Tuba)  )

◆ W_Tuba_HasPlayed()

bool W_Tuba_HasPlayed ( entity pl,
.entity weaponentity,
string melody,
int instrument,
bool ignorepitch,
float mintempo,
float maxtempo )

Definition at line 13 of file tuba.qc.

14{
15 float i, j, mmin, mmax, nolength;
16 float n = tokenize_console(melody);
17 if(n > pl.(weaponentity).tuba_lastnotes_cnt)
18 return false;
19 float pitchshift = 0;
20
21 if(instrument >= 0)
22 if(pl.(weaponentity).tuba_instrument != instrument)
23 return false;
24
25 // verify notes...
26 nolength = false;
27 for(i = 0; i < n; ++i)
28 {
29 vector v = pl.(weaponentity).(tuba_lastnotes[(pl.(weaponentity).tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
30 float ai = stof(argv(n - i - 1));
31 float np = floor(ai);
32 if(ai == np)
33 nolength = true;
34 // n counts the last played notes BACKWARDS
35 // _x is start
36 // _y is end
37 // _z is note pitch
38 if(ignorepitch && i == 0)
39 {
40 pitchshift = np - v.z;
41 }
42 else
43 {
44 if(v.z + pitchshift != np)
45 return false;
46 }
47 }
48
49 // now we know the right NOTES were played
50 if(!nolength)
51 {
52 // verify rhythm...
53 float ti = 0;
54 if(maxtempo > 0)
55 mmin = 240 / maxtempo; // 60 = "0.25 means 1 sec", at 120 0.5 means 1 sec, at 240 1 means 1 sec
56 else
57 mmin = 0;
58 if(mintempo > 0)
59 mmax = 240 / mintempo; // 60 = "0.25 means 1 sec", at 120 0.5 means 1 sec, at 240 1 means 1 sec
60 else
61 mmax = 240; // you won't try THAT hard... (tempo 1)
62 //printf("initial tempo rules: %f %f\n", mmin, mmax);
63
64 for(i = 0; i < n; ++i)
65 {
66 vector vi = pl.(weaponentity).(tuba_lastnotes[(pl.(weaponentity).tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
67 float ai = stof(argv(n - i - 1));
68 ti -= 1 / (ai - floor(ai));
69 float tj = ti;
70 for(j = i+1; j < n; ++j)
71 {
72 vector vj = pl.(weaponentity).(tuba_lastnotes[(pl.(weaponentity).tuba_lastnotes_last - j + MAX_TUBANOTES) % MAX_TUBANOTES]);
73 float aj = stof(argv(n - j - 1));
74 tj -= (aj - floor(aj));
75
76 // note i should be at m*ti+b
77 // note j should be at m*tj+b
78 // so:
79 // we have a LINE l, so that
80 // vi_x <= l(ti) <= vi_y
81 // vj_x <= l(tj) <= vj_y
82 // what is m?
83
84 // vi_x <= vi_y <= vj_x <= vj_y
85 // ti <= tj
86 //printf("first note: %f to %f, should be %f\n", vi_x, vi_y, ti);
87 //printf("second note: %f to %f, should be %f\n", vj_x, vj_y, tj);
88 //printf("m1 = %f\n", (vi_x - vj_y) / (ti - tj));
89 //printf("m2 = %f\n", (vi_y - vj_x) / (ti - tj));
90 mmin = max(mmin, (vi.x - vj.y) / (ti - tj)); // lower bound
91 mmax = min(mmax, (vi.y - vj.x) / (ti - tj)); // upper bound
92 }
93 }
94
95 if(mmin > mmax) // rhythm fail
96 return false;
97 }
98
99 pl.(weaponentity).tuba_lastnotes_cnt = 0;
100
101 return true;
102}
#define tokenize_console
float stof(string val,...)
float min(float f,...)
float floor(float f)
string argv(float n)
float max(float f,...)
vector
Definition self.qh:92
vector tuba_lastnotes[MAX_TUBANOTES]
Definition tuba.qc:11
float tuba_lastnotes_cnt
Definition tuba.qc:10
#define MAX_TUBANOTES
Definition tuba.qc:8

References argv(), entity(), floor(), max(), MAX_TUBANOTES, min(), stof(), tokenize_console, tuba_lastnotes, tuba_lastnotes_cnt, and vector.

Referenced by trigger_magicear_processmessage().

Variable Documentation

◆ autocvar_cl_tuba_attenuation

float autocvar_cl_tuba_attenuation = 0.5

Definition at line 14 of file tuba.qh.

Referenced by tubasound().

◆ autocvar_cl_tuba_fadetime

float autocvar_cl_tuba_fadetime = 0.25

Definition at line 15 of file tuba.qh.

Referenced by Ent_TubaNote_Think().

◆ autocvar_cl_tuba_pitchstep

float autocvar_cl_tuba_pitchstep = 6

Definition at line 16 of file tuba.qh.

Referenced by PRECACHE().

◆ autocvar_cl_tuba_volume

float autocvar_cl_tuba_volume = 1

Definition at line 17 of file tuba.qh.

Referenced by Ent_TubaNote_UpdateSound().

◆ autocvar_snd_soundradius

float autocvar_snd_soundradius

Definition at line 71 of file tuba.qh.

Referenced by W_Tuba_NoteThink().