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 41 of file tuba.qh.

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

Referenced by W_Tuba_NoteThink().