]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_tuba.qc
Merge remote branch 'origin/master' into samual/hud_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_tuba.qc
index 0973c5f92a8a24c4da171faa91e64f24cfe05f6e..79f12f55f8a0aa4636b91df84b3887fd95cf46b1 100644 (file)
@@ -3,15 +3,9 @@ REGISTER_WEAPON(TUBA, w_tuba, 0, 1, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH, BOT_PICKU
 #else
 #ifdef SVQC
 //#define TUBA_NOTE(n) strcat("weapons/tuba_note", ftos(n), ".wav")
-.float tuba_notecount;
 .entity tuba_note;
 .float tuba_smoketime;
-
-void W_Tuba_SetAmmoCounter()
-{
-       // this weapon doesn't have a reload system, so always set the clip to 0 when switching to it
-       self.clip_load = self.clip_size = 0; // also keeps crosshair ammo from displaying
-}
+.float tuba_instrument;
 
 float Tuba_GetNote(entity pl, float hittype)
 {
@@ -54,7 +48,7 @@ float Tuba_GetNote(entity pl, float hittype)
        // kind of tuba currently is player slot number, or team number if in
        // teamplay
        // that way, holes in the range of notes are "plugged"
-       if(teams_matter)
+       if(teamplay)
        {
                if(pl.team == COLOR_TEAM2 || pl.team == COLOR_TEAM4)
                        note += 3;
@@ -82,14 +76,24 @@ float Tuba_GetNote(entity pl, float hittype)
 
 float W_Tuba_NoteSendEntity(entity to, float sf)
 {
+       float f;
+
        WriteByte(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
-       WriteByte(MSG_ENTITY, (sf & 1) | ((self.cnt + 42) * 2));
+       WriteByte(MSG_ENTITY, sf);
        if(sf & 1)
+       {
+               WriteChar(MSG_ENTITY, self.cnt);
+               f = 0;
+               if(self.realowner != to)
+                       f |= 1;
+               f |= 2 * self.tuba_instrument;
+               WriteByte(MSG_ENTITY, f);
+       }
+       if(sf & 2)
        {
                WriteCoord(MSG_ENTITY, self.origin_x);
                WriteCoord(MSG_ENTITY, self.origin_y);
                WriteCoord(MSG_ENTITY, self.origin_z);
-               WriteByte(MSG_ENTITY, self.owner != to);
        }
        return TRUE;
 }
@@ -103,31 +107,31 @@ void W_Tuba_NoteThink()
        entity e;
        if(time > self.teleport_time)
        {
-               self.owner.tuba_note = world;
+               self.realowner.tuba_note = world;
                remove(self);
                return;
        }
        self.nextthink = time;
        dist_mult = autocvar_g_balance_tuba_attenuation / autocvar_snd_soundradius;
        FOR_EACH_REALCLIENT(e)
-       if(e != self.owner)
+       if(e != self.realowner)
        {
                v = self.origin - (e.origin + e.view_ofs);
                vol0 = max(0, 1 - vlen(v) * dist_mult);
                dir0 = normalize(v);
-               v = self.owner.origin - (e.origin + e.view_ofs);
+               v = self.realowner.origin - (e.origin + e.view_ofs);
                vol1 = max(0, 1 - vlen(v) * dist_mult);
                dir1 = normalize(v);
                if(fabs(vol0 - vol1) > 0.005) // 0.5 percent change in volume
                {
-                       setorigin(self, self.owner.origin);
-                       self.SendFlags |= 1;
+                       setorigin(self, self.realowner.origin);
+                       self.SendFlags |= 2;
                        break;
                }
                if(dir0 * dir1 < 0.9994) // 2 degrees change in angle
                {
-                       setorigin(self, self.owner.origin);
-                       self.SendFlags |= 1;
+                       setorigin(self, self.realowner.origin);
+                       self.SendFlags |= 2;
                        break;
                }
        }
@@ -136,29 +140,15 @@ void W_Tuba_NoteThink()
 void W_Tuba_Attack(float hittype)
 {
        vector o;
-       float c, n;
+       float n;
        W_SetupShot(self, FALSE, 2, "", 0, autocvar_g_balance_tuba_damage);
-       if(self.tuba_notecount)
-       {
-               self.tuba_notecount = FALSE;
-               c = CHAN_WEAPON;
-       }
-       else
-       {
-               self.tuba_notecount = TRUE;
-               c = CHAN_WEAPON2;
-       }
 
        n = Tuba_GetNote(self, hittype);
 
        if(self.tuba_note)
        {
-               if(self.tuba_note.cnt != n)
+               if(self.tuba_note.cnt != n || self.tuba_note.tuba_instrument != self.tuba_instrument)
                {
-                       /*
-                       self.tuba_note.cnt = n;
-                       self.tuba_note.SendFlags |= 2;
-                       */
                        remove(self.tuba_note);
                        self.tuba_note = world;
                }
@@ -167,14 +157,15 @@ void W_Tuba_Attack(float hittype)
        if not(self.tuba_note)
        {
                self.tuba_note = spawn();
-               self.tuba_note.owner = self;
+               self.tuba_note.owner = self.tuba_note.realowner = self;
                self.tuba_note.cnt = n;
+               self.tuba_note.tuba_instrument = self.tuba_instrument;
                self.tuba_note.think = W_Tuba_NoteThink;
                self.tuba_note.nextthink = time;
                Net_LinkEntity(self.tuba_note, FALSE, 0, W_Tuba_NoteSendEntity);
        }
 
-       self.tuba_note.teleport_time = time + autocvar_g_balance_tuba_refire * 2; // so it can get prolonged safely
+       self.tuba_note.teleport_time = time + autocvar_g_balance_tuba_refire * 2 * W_WeaponRateFactor(); // so it can get prolonged safely
 
        //sound(self, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), autocvar_g_balance_tuba_attenuation);
        RadiusDamage(self, self, autocvar_g_balance_tuba_damage, autocvar_g_balance_tuba_edgedamage, autocvar_g_balance_tuba_radius, world, autocvar_g_balance_tuba_force, hittype | WEP_TUBA, world);
@@ -244,7 +235,31 @@ float w_tuba(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_TUBA);
-               W_Porto_SetAmmoCounter();
+               self.current_ammo = ammo_none;
+       }
+       else if (req == WR_RELOAD)
+       {
+               // TODO switch to alternate instruments :)
+               if(self.weaponentity.state == WS_READY)
+               {
+                       /*
+                       switch(self.tuba_instrument)
+                       {
+                               case 0:
+                                       self.tuba_instrument = 1;
+                                       self.weaponname = "laser";
+                                       break;
+                               case 1:
+                                       self.tuba_instrument = 0;
+                                       self.weaponname = "tuba";
+                                       break;
+                       }
+                       */
+                       W_SetupShot(self, FALSE, 0, "", 0, 0);
+                       pointparticles(particleeffectnum("teleport"), w_shotorg, '0 0 0', 1);
+                       self.weaponentity.state = WS_INUSE;
+                       weapon_thinkf(WFRAME_RELOAD, 0.5, w_ready);
+               }
        }
        else if (req == WR_CHECKAMMO1)
                return TRUE; // TODO use fuel?