]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Viewmodels: fix arc repeating fire animation
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 6 Nov 2015 09:50:45 +0000 (20:50 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Fri, 6 Nov 2015 09:50:45 +0000 (20:50 +1100)
qcsrc/client/view.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/server/weapons/weaponsystem.qc

index f1e107de2f0c8e8faebee4f30acc2443c29a33a9..6fc6bbfa25c8914eb1b7fff6c544d718a10bc8f2 100644 (file)
@@ -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
index 177d12c2d36d54e221be9ef5aec6145c09e2f5ea..77934ec004ed63da3f6a261b224349bb496fe664 100644 (file)
@@ -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;
index 218edb6a86fb2e9c0ad0d9eb0195baaa9e6f7545..1fa8131363ec872fb8ab33b7e62765dde77a6dcb 100644 (file)
@@ -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))
index 930bb9065cff943e92ea5749c41f6d86594bcae4..54bc2c9a5f2dba2336a7b7a47ed73d9f9d9fe891 100644 (file)
@@ -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))