From 6b37950bed7d153eaca5d37f3fc3585c0e83bb6d Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 6 Nov 2015 20:50:45 +1100 Subject: [PATCH] Viewmodels: fix arc repeating fire animation --- qcsrc/client/view.qc | 8 ++++---- qcsrc/common/weapons/all.qc | 2 +- qcsrc/common/weapons/weapon/arc.qc | 2 +- qcsrc/server/weapons/weaponsystem.qc | 28 ++++++++++++---------------- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index f1e107de2..6fc6bbfa2 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -53,15 +53,15 @@ void viewmodel_draw(entity this) } { static string name_last; - string name = get_weaponinfo(activeweapon).mdl; + string name = Weapons_from(activeweapon).mdl; if (name != name_last) { name_last = name; CL_WeaponEntity_SetModel(this, name); - updateanim(this); - if (!this.animstate_override) - setanim(this, this.anim_idle, true, false, false); } + anim_update(this); + if (!this.animstate_override) + anim_set(this, this.anim_idle, true, false, false); } float eta = (getstatf(STAT_WEAPON_NEXTTHINK) - time); // TODO: / W_WeaponRateFactor(); float f = 0; // 0..1; 0: fully active diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 177d12c2d..77934ec00 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -580,7 +580,7 @@ NET_HANDLE(wframe, bool isNew) a.y = ReadCoord(); a.z = ReadCoord(); bool restartanim = ReadByte(); - setanim(viewmodel, a, restartanim == false, restartanim, restartanim); + anim_set(viewmodel, a, !restartanim, restartanim, restartanim); viewmodel.state = ReadByte(); viewmodel.alpha = ReadByte() / 255; return true; diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 218edb6a8..1fa813136 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -670,7 +670,7 @@ void Arc_Smoke() weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready); else #endif - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), w_ready); } if((!actor.arc_beam) || wasfreed(actor.arc_beam)) diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 930bb9065..54bc2c9a5 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -92,16 +92,13 @@ void CL_Weaponentity_Think() CL_WeaponEntity_SetModel(this, this.owner.weaponname); } - this.effects = EF_NODRAW; // TODO: don't render this entity at all + this.effects = EF_NODRAW; // TODO: don't render this entity at all if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha; else if (this.owner.alpha != 0) this.alpha = this.owner.alpha; else this.alpha = 1; - if (this.weaponchild) - { - this.weaponchild.effects = this.effects; - } + if (this.weaponchild) this.weaponchild.effects = this.effects; } void CL_ExteriorWeaponentity_Think() @@ -218,7 +215,7 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary if (mine.owner == actor) return false; if (thiswep == WEP_SHOTGUN) - if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow + if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow if (thiswep == Weapons_from(actor.switchweapon) && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons { @@ -315,6 +312,10 @@ bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bo void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim); +/** + * @param t defer thinking until time + t + * @param func next think function + */ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func) { @@ -325,13 +326,9 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void( fr = this.wframe; restartanim = false; } - else if (fr == WFRAME_IDLE) - { - restartanim = false; - } else { - restartanim = true; + restartanim = fr != WFRAME_IDLE; } vector of = v_forward; @@ -348,9 +345,8 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void( else // if (fr == WFRAME_RELOAD) a = this.anim_reload; a.z *= g_weaponratefactor; - entity e; FOR_EACH_CLIENT(e) if (e == actor || (IS_SPEC(e) && e.enemy == actor)) { - wframe_send(e, this, a, restartanim); - } + entity e; + FOR_EACH_CLIENT(e) if (e == actor || (IS_SPEC(e) && e.enemy == actor)) wframe_send(e, this, a, restartanim); } v_forward = of; @@ -406,11 +402,11 @@ bool forbidWeaponUse(entity player) void W_WeaponFrame(entity actor) { - .entity weaponentity = weaponentities[0]; // TODO: unhardcode + .entity weaponentity = weaponentities[0]; // TODO: unhardcode entity this = actor.(weaponentity); if (frametime) actor.weapon_frametime = frametime; - if (!this || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands + if (!this || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands if (forbidWeaponUse(actor)) -- 2.39.2