]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_tuba.qc
Here it is: the @!#%'n Tuba.
[divverent/nexuiz.git] / data / qcsrc / server / w_tuba.qc
1 float Tuba_GetNote(entity pl, float hittype)
2 {
3         float note;
4         float movestate;
5         print(etos(pl), "\n");
6         movestate = 5;
7         if(pl.movement_x < 0) movestate -= 3;
8         if(pl.movement_x > 0) movestate += 3;
9         if(pl.movement_y < 0) movestate -= 1;
10         if(pl.movement_y > 0) movestate += 1;
11         switch(movestate)
12         {
13                 case 1: note = -6; break; // Gb
14                 case 2: note = -5; break; // G
15                 case 3: note = -4; break; // G#
16                 case 4: note = -1; break; // B
17                 case 5: note =  0; break; // c
18                 case 6: note = +2; break; // d
19                 case 7: note = +3; break; // eb
20                 case 8: note = +4; break; // e
21                 case 9: note = +5; break; // e#
22         }
23         print(ftos(movestate), "\n");
24         if(pl.BUTTON_CROUCH)
25                 note -= 12;
26         if(hittype & HITTYPE_SECONDARY)
27                 note += 7;
28         
29         // total range of notes:
30         //                       0
31         //                 ***  ** ****
32         //                        ***  ** ****
33         //     ***  ** ****
34         //            ***  ** ****
35         //     -18.........................+12
36         return note;
37 }
38
39 void W_Tuba_Attack(float hittype)
40 {
41         W_SetupShot(self, FALSE, 2, "");
42         sound(self, CHAN_WEAPON, strcat("weapons/tuba_note", ftos(Tuba_GetNote(self, hittype)), ".wav"), VOL_BASE, cvar("g_balance_tuba_attenuation"));
43         RadiusDamage(self, self, cvar("g_balance_tuba_damage"), cvar("g_balance_tuba_edgedamage"), cvar("g_balance_tuba_radius"), world, cvar("g_balance_tuba_force"), hittype | WEP_TUBA, world);
44 }
45
46 void spawnfunc_weapon_tuba (void)
47 {
48         error("The tuba does not work yet. Forget it.");
49         weapon_defaultspawnfunc(WEP_TUBA);
50 }
51
52 float w_tuba(float req)
53 {
54         if (req == WR_AIM)
55         {
56                 // bots cannot play the Tuba yet
57                 // I think they should start with the recorder first
58         }
59         else if (req == WR_THINK)
60         {
61                 if (self.BUTTON_ATCK)
62                 if (weapon_prepareattack(0, cvar("g_balance_tuba_refire")))
63                 {
64                         W_Tuba_Attack(0);
65                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_tuba_animtime"), w_ready);
66                 }
67                 if (self.BUTTON_ATCK2)
68                 if (weapon_prepareattack(1, cvar("g_balance_tuba_refire")))
69                 {
70                         W_Tuba_Attack(HITTYPE_SECONDARY);
71                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_tuba_animtime"), w_ready);
72                 }
73         }
74         else if (req == WR_PRECACHE)
75         {
76                 precache_model ("models/weapons/g_tuba.md3");
77                 precache_model ("models/weapons/v_tuba.md3");
78                 precache_model ("models/weapons/h_tuba.dpm");
79         }
80         else if (req == WR_SETUP)
81                 weapon_setup(WEP_TUBA);
82         else if (req == WR_CHECKAMMO1)
83                 return TRUE; // TODO use fuel?
84         else if (req == WR_CHECKAMMO2)
85                 return TRUE; // TODO use fuel?
86         else if (req == WR_SUICIDEMESSAGE)
87         {
88                 w_deathtypestring = "hurt his own ears";
89         }
90         else if (req == WR_KILLMESSAGE)
91         {
92                 w_deathtypestring = "died of #'s great playing";
93         }
94         return TRUE;
95 };