]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Save the .tuba_instrument field clientside DefaultUser/tubafix 352/head
authorFreddy <schro.sb@gmail.com>
Wed, 5 Oct 2016 14:38:18 +0000 (16:38 +0200)
committerFreddy <schro.sb@gmail.com>
Wed, 5 Oct 2016 14:38:18 +0000 (16:38 +0200)
use it to draw the viewmodel

qcsrc/client/view.qc
qcsrc/common/weapons/weapon/tuba.qc

index ee2e2c0b506c320ec126cfcf3bb1ff1fff879443..72f702b8dfeb5bdeb3ba93639c35131c0f4c8b73 100644 (file)
@@ -280,6 +280,7 @@ void viewmodel_animate(entity this)
 .float weapon_nextthink;
 .float weapon_eta_last;
 .float weapon_switchdelay;
+.float tuba_instrument;
 
 void viewmodel_draw(entity this)
 {
@@ -312,6 +313,13 @@ void viewmodel_draw(entity this)
                static string name_last;
                string name = wep.mdl;
                bool swap = name != name_last;
+               if (wep == WEP_TUBA)
+               {
+                       int i = me.tuba_instrument;
+                       name = (i == 0) ? "tuba" :
+                              (i == 1) ? "akordeon" :
+                                         "kleinbottle" ;
+               }
 //             if (swap)
                {
                        name_last = name;
index 7ed417428f6151f812c475e6abf6f4347b00e600..d868b9c89c879e459c33e2aca41f09d80403a4c3 100644 (file)
@@ -42,11 +42,11 @@ REGISTER_WEAPON(TUBA, tuba, NEW(Tuba));
 
 #ifdef IMPLEMENTATION
 
+.float tuba_instrument;
 #ifdef SVQC
 
 .entity tuba_note;
 .float tuba_smoketime;
-.float tuba_instrument;
 
 #define MAX_TUBANOTES 32
 .float tuba_lastnotes_last;
@@ -394,12 +394,6 @@ METHOD(Tuba, wr_think, void(Tuba this, entity actor, .entity weaponentity, int f
                }
        }
 }
-
-METHOD(Tuba, wr_setup, void(Tuba this, entity actor))
-{
-       actor.ammo_field = ammo_none;
-//     actor.tuba_instrument = 0;
-}
 #endif
 
 REGISTER_NET_S2C(tuba_instrument)
@@ -411,7 +405,7 @@ NET_HANDLE(tuba_instrument, bool)
        string s = (i == 0) ? "tuba" :
                   (i == 1) ? "akordeon" :
                              "kleinbottle" ;
-       activeweapon.mdl = s;
+       csqcplayer.tuba_instrument = i;
        CL_WeaponEntity_SetModel(viewmodel, s, true);
 }
 #endif
@@ -428,6 +422,14 @@ SPECTATE_COPY()
        if (this.tuba_instrument != spectatee.tuba_instrument)
                tuba_instrument_send(this, this.tuba_instrument = spectatee.tuba_instrument);
 }
+
+METHOD(Tuba, wr_setup, void(Tuba this, entity actor))
+{
+       actor.ammo_field = ammo_none;
+       actor.tuba_instrument = 0;
+       tuba_instrument_send(actor, actor.tuba_instrument);
+}
+
 METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
 {
        // switch to alternate instruments :)