From: Freddy Date: Wed, 5 Oct 2016 14:38:18 +0000 (+0200) Subject: Save the .tuba_instrument field clientside X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2FDefaultUser%2Ftubafix;p=xonotic%2Fxonotic-data.pk3dir.git Save the .tuba_instrument field clientside use it to draw the viewmodel --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index ee2e2c0b5..72f702b8d 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 7ed417428..d868b9c89 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -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 :)