From: TimePath Date: Mon, 30 Nov 2015 01:55:56 +0000 (+1100) Subject: Viewmodels: network switchdelays X-Git-Tag: xonotic-v0.8.2~1601^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6e72daa3bb2c53eb6797e40226339ff719b054a1;p=xonotic%2Fxonotic-data.pk3dir.git Viewmodels: network switchdelays --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index df4a6d335..09bfd4544 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -266,6 +266,7 @@ void viewmodel_animate(entity this) .vector viewmodel_origin, viewmodel_angles; .float weapon_nextthink; .float weapon_eta_last; +.float weapon_switchdelay; void viewmodel_draw(entity this) { @@ -309,16 +310,12 @@ void viewmodel_draw(entity this) { case WS_RAISE: { - // entity newwep = Weapons_from(activeweapon); - float delay = 0.2; // TODO: newwep.switchdelay_raise; - f = eta / max(eta, delay); + f = eta / max(eta, this.weapon_switchdelay); break; } case WS_DROP: { - // entity oldwep = Weapons_from(activeweapon); - float delay = 0.2; // TODO: newwep.switchdelay_drop; - f = 1 - eta / max(eta, delay); + f = 1 - eta / max(eta, this.weapon_switchdelay); break; } case WS_CLEAR: diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index ab613bb94..d95bf1260 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -563,6 +563,16 @@ NET_HANDLE(wframe, bool isNew) viewmodel.state = ReadByte(); viewmodel.weapon_nextthink = ReadFloat(); viewmodel.alpha = ReadByte() / 255; + switch (viewmodel.state) + { + case WS_RAISE: + case WS_DROP: + viewmodel.weapon_switchdelay = ReadFloat(); + break; + default: + viewmodel.weapon_switchdelay = 0; + break; + } return true; } #endif @@ -581,6 +591,16 @@ void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim) WriteByte(channel, weaponentity.state); WriteFloat(channel, weaponentity.weapon_nextthink); WriteByte(channel, weaponentity.alpha * 255); + Weapon w = Weapons_from(actor.weapon); + switch (weaponentity.state) + { + case WS_RAISE: + WriteFloat(channel, w.switchdelay_raise); + break; + case WS_DROP: + WriteFloat(channel, w.switchdelay_drop); + break; + } } #endif