]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix animations when weapon states do not match
authorMario <mario@smbclan.net>
Thu, 29 Sep 2016 12:36:00 +0000 (22:36 +1000)
committerMario <mario@smbclan.net>
Thu, 29 Sep 2016 12:36:00 +0000 (22:36 +1000)
qcsrc/client/view.qc
qcsrc/common/mutators/mutator/nix/sv_nix.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/common/wepent.qc
qcsrc/common/wepent.qh
qcsrc/server/client.qc
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/weaponsystem.qc

index 36c0d1bc8c6d349eec4f7272c5cd5f4f0c8988c6..27921b182dd88b6640e7bee3ad61e3c1f5783cb3 100644 (file)
@@ -281,6 +281,8 @@ void viewmodel_animate(entity this)
 .float weapon_eta_last;
 .float weapon_switchdelay;
 
+.string name_last;
+
 void viewmodel_draw(entity this)
 {
        if(!this.activeweapon || !autocvar_r_drawviewmodel)
@@ -294,7 +296,7 @@ void viewmodel_draw(entity this)
        wasinvehicle = invehicle;
        Weapon wep = this.activeweapon;
        int c = entcs_GetClientColors(current_player);
-       vector g = weaponentity_glowmod(wep, NULL, c);
+       vector g = weaponentity_glowmod(wep, NULL, c, this);
        entity me = CSQCModel_server2csqc(player_localentnum - 1);
        int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
                | EF_NODEPTHTEST)
@@ -309,12 +311,11 @@ void viewmodel_draw(entity this)
                CSQCModel_Effects_Apply(e);
        }
        {
-               static string name_last;
                string name = wep.mdl;
-               bool swap = name != name_last;
+               bool swap = name != this.name_last;
                // if (swap)
                {
-                       name_last = name;
+                       this.name_last = name;
                        CL_WeaponEntity_SetModel(this, name, swap);
                        this.viewmodel_origin = this.origin;
                        this.viewmodel_angles = this.angles;
index 9ea34f2894cda6e37b0678ef15eb14a3eb2fcbb8..01b8a50c5508d0911a7dee2270ad2a29e5535bc3 100644 (file)
@@ -172,7 +172,11 @@ void NIX_GiveCurrentWeapon(entity this)
                {
                        if(WEP_CVAR_SEC(vortex, chargepool))
                                this.vortex_chargepool_ammo = 1;
-                       this.vortex_charge = WEP_CVAR(vortex, charge_start);
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                       {
+                               .entity weaponentity = weaponentities[slot];
+                               this.(weaponentity).vortex_charge = WEP_CVAR(vortex, charge_start);
+                       }
                }
 
                // set last change info
index 12e26ac4e2bcf328490a1fc36094cf9a5f72983e..071ac4c565a7e1f076674b40ecb8d85a34110816 100644 (file)
@@ -326,10 +326,10 @@ STATIC_INIT(register_weapons_done)
 
 .entity weaponchild;
 .entity exteriorweaponentity;
-vector weaponentity_glowmod(Weapon wep, entity actor, int c)
+vector weaponentity_glowmod(Weapon wep, entity actor, int c, entity wepent)
 {
     vector g;
-    if (!(g = wep.wr_glow(wep, actor))) g = colormapPaletteColor(c & 0x0F, true) * 2;
+    if (!(g = wep.wr_glow(wep, actor, wepent))) g = colormapPaletteColor(c & 0x0F, true) * 2;
     return g;
 }
 
index d16d733d5989a13ea7284ae0385da9f1c1d4d9f4..fc116721825697485730ed0ee5bdfd4a0e3224ac 100644 (file)
@@ -118,7 +118,7 @@ CLASS(Weapon, Object)
         return false;
     }
     /** (CLIENT) weapon specific glow */
-    METHOD(Weapon, wr_glow, vector(Weapon this, entity actor)) { return '0 0 0'; }
+    METHOD(Weapon, wr_glow, vector(Weapon this, entity actor, entity wepent)) { return '0 0 0'; }
     /** (SERVER) the weapon is dropped */
     METHOD(Weapon, wr_drop, void(Weapon this, entity actor)) {}
     /** (SERVER) a weapon is picked up */
index 660c7549fd8d76e8698de2189945f43018ac0293..351f8fc27a603acf68fd67f46b0505e8230a0667 100644 (file)
@@ -78,10 +78,10 @@ float autocvar_g_weapon_charge_colormod_blue_half;
 float autocvar_g_weapon_charge_colormod_green_half;
 float autocvar_g_weapon_charge_colormod_hdrmultiplier;
 
-METHOD(Vortex, wr_glow, vector(Vortex this, entity actor))
+METHOD(Vortex, wr_glow, vector(Vortex this, entity actor, entity wepent))
 {
        if (!STAT(WEP_CVAR_vortex_charge, actor)) return '0 0 0';
-       float charge = STAT(VORTEX_CHARGE, actor);
+       float charge = wepent.vortex_charge;
        float animlimit = STAT(WEP_CVAR_vortex_charge_animlimit, actor);
        vector g;
        g.x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, charge / animlimit);
@@ -155,7 +155,7 @@ MUTATOR_HOOKFUNCTION(vortex_charge, GetPressedKeys)
                xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed));
                float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed));
                // add the extra charge
-               player.vortex_charge = min(1, player.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
+               player.(weaponentity).vortex_charge = min(1, player.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
        }
 }
 
@@ -176,8 +176,8 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
 
        if(WEP_CVAR(vortex, charge))
        {
-               charge = WEP_CVAR(vortex, charge_mindmg) / mydmg + (1 - WEP_CVAR(vortex, charge_mindmg) / mydmg) * actor.vortex_charge;
-               actor.vortex_charge *= WEP_CVAR(vortex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
+               charge = WEP_CVAR(vortex, charge_mindmg) / mydmg + (1 - WEP_CVAR(vortex, charge_mindmg) / mydmg) * actor.(weaponentity).vortex_charge;
+               actor.(weaponentity).vortex_charge *= WEP_CVAR(vortex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
                // O RLY? -- divVerent
                // YA RLY -- FruitieX
        }
@@ -226,17 +226,23 @@ METHOD(Vortex, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(WEP_CVAR(vortex, charge) && actor.vortex_charge < WEP_CVAR(vortex, charge_limit))
-        actor.vortex_charge = min(1, actor.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME);
+    if(WEP_CVAR(vortex, charge) && actor.(weaponentity).vortex_charge < WEP_CVAR(vortex, charge_limit))
+        actor.(weaponentity).vortex_charge = min(1, actor.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME);
+
+    if(weaponslot(weaponentity) == 0)
+        actor.vortex_charge = actor.(weaponentity).vortex_charge;
 
     if(WEP_CVAR_SEC(vortex, chargepool))
-        if(actor.vortex_chargepool_ammo < 1)
+        if(actor.(weaponentity).vortex_chargepool_ammo < 1)
         {
             if(actor.vortex_chargepool_pauseregen_finished < time)
-                actor.vortex_chargepool_ammo = min(1, actor.vortex_chargepool_ammo + WEP_CVAR_SEC(vortex, chargepool_regen) * frametime / W_TICSPERFRAME);
+                actor.(weaponentity).vortex_chargepool_ammo = min(1, actor.(weaponentity).vortex_chargepool_ammo + WEP_CVAR_SEC(vortex, chargepool_regen) * frametime / W_TICSPERFRAME);
             actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(vortex, chargepool_pause_regen));
         }
 
+    if(weaponslot(weaponentity) == 0)
+        actor.vortex_chargepool_ammo = actor.(weaponentity).vortex_chargepool_ammo;
+
     if(autocvar_g_balance_vortex_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else
@@ -253,10 +259,10 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         {
             if(WEP_CVAR(vortex, charge))
             {
-                actor.vortex_charge_rottime = time + WEP_CVAR(vortex, charge_rot_pause);
+                actor.(weaponentity).vortex_charge_rottime = time + WEP_CVAR(vortex, charge_rot_pause);
                 float dt = frametime / W_TICSPERFRAME;
 
-                if(actor.vortex_charge < 1)
+                if(actor.(weaponentity).vortex_charge < 1)
                 {
                     if(WEP_CVAR_SEC(vortex, chargepool))
                     {
@@ -265,12 +271,12 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
                             // always deplete if secondary is held
                             actor.vortex_chargepool_ammo = max(0, actor.vortex_chargepool_ammo - WEP_CVAR_SEC(vortex, ammo) * dt);
 
-                            dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
+                            dt = min(dt, (1 - actor.(weaponentity).vortex_charge) / WEP_CVAR(vortex, charge_rate));
                             actor.vortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(vortex, chargepool_pause_regen);
                             dt = min(dt, actor.vortex_chargepool_ammo);
                             dt = max(0, dt);
 
-                            actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
+                            actor.(weaponentity).vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
                         }
                     }
 
@@ -278,7 +284,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
                     {
                         if(fire & 2) // only eat ammo when the button is pressed
                         {
-                            dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
+                            dt = min(dt, (1 - actor.(weaponentity).vortex_charge) / WEP_CVAR(vortex, charge_rate));
                             if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                             {
                                 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
@@ -302,14 +308,14 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
                                     }
                                 }
                             }
-                            actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
+                            actor.(weaponentity).vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
                         }
                     }
 
                     else
                     {
-                        dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
-                        actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
+                        dt = min(dt, (1 - actor.(weaponentity).vortex_charge) / WEP_CVAR(vortex, charge_rate));
+                        actor.(weaponentity).vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
                     }
                 }
             }
@@ -355,6 +361,14 @@ METHOD(Vortex, wr_resetplayer, void(entity thiswep, entity actor))
             actor.vortex_chargepool_ammo = 1;
         }
         actor.vortex_charge = WEP_CVAR(vortex, charge_start);
+        for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+        {
+            .entity weaponentity = weaponentities[slot];
+            actor.(weaponentity).vortex_charge = WEP_CVAR(vortex, charge_start);
+
+            if (WEP_CVAR_SEC(vortex, chargepool))
+                actor.(weaponentity).vortex_chargepool_ammo = 1;
+        }
     }
     actor.vortex_lasthit = 0;
 }
index cfd846d0c5df19179be8e4a48e5caab4f49dca8c..0d18908c46d98438f6d0965e9d8031a0bc5d604f 100644 (file)
@@ -16,6 +16,7 @@ MACRO_END
 .Weapon w_m_weapon;
 //.float w_weapon_nextthink;
 .float w_m_alpha;
+.float w_vortex_charge;
 
 // #define PROP(public, fld, set, sv, cl)
 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
@@ -34,6 +35,10 @@ MACRO_END
     PROP(false, m_alpha, WEPENT_SET_NORMAL, \
        { WriteByte(chan, this.m_alpha * 16); }, \
        { (viewmodels[this.m_wepent_slot]).alpha = ReadByte() / 16; }) \
+    \
+    PROP(false, vortex_charge, WEPENT_SET_NORMAL, \
+       { WriteByte(chan, this.vortex_charge * 16); }, \
+       { (viewmodels[this.m_wepent_slot]).vortex_charge = ReadByte() / 16; }) \
     \
        /**/
 
index 77296018da9374ec95e32c25b5a8241060789fd2..0064b1f61c9a532628b6e4d5b2924291b66d8fba 100644 (file)
@@ -3,6 +3,8 @@
 REGISTER_NET_LINKED(ENT_CLIENT_WEPENT)
 REGISTER_NET_TEMP(CLIENT_WEPENT)
 
+.float vortex_charge;
+
 #ifdef SVQC
 
        bool wepent_send(entity this, entity to, int sf);
index d6805263ce9c3d9ffdd955dc50185bcde9cc44ba..2023cb0e6b4630dba0bf7b3d267304cda90f6afb 100644 (file)
@@ -2445,8 +2445,12 @@ void PlayerPreThink (entity this)
 
                // WEAPONTODO: Add a weapon request for this
                // rot vortex charge to the charge limit
-               if (WEP_CVAR(vortex, charge_rot_rate) && this.vortex_charge > WEP_CVAR(vortex, charge_limit) && this.vortex_charge_rottime < time)
-                       this.vortex_charge = bound(WEP_CVAR(vortex, charge_limit), this.vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1);
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if (WEP_CVAR(vortex, charge_rot_rate) && this.(weaponentity).vortex_charge > WEP_CVAR(vortex, charge_limit) && this.(weaponentity).vortex_charge_rottime < time)
+                               this.(weaponentity).vortex_charge = bound(WEP_CVAR(vortex, charge_limit), this.(weaponentity).vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1);
+               }
 
                if (frametime) player_anim(this);
 
index 47531ecbbdc36f98102b57d05b9bb0a7073172ce..f3a72412bb1955abad7f2f7537c3dc021bfccccd 100644 (file)
@@ -45,7 +45,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        wep.owner = wep.enemy = own;
        wep.flags |= FL_TOSSED;
        wep.colormap = own.colormap;
-       wep.glowmod = weaponentity_glowmod(info, own, own.clientcolors);
+       wep.glowmod = weaponentity_glowmod(info, own, own.clientcolors, own.(weaponentity));
 
        W_DropEvent(wr_drop,own,wpn,wep);
 
index 0dffe0289439079d6a3fb0c7d977625e2cb60eb0..f5330d08edf2a963bdc3e0fdf8c52c734a3674bb 100644 (file)
@@ -158,7 +158,7 @@ void CL_ExteriorWeaponentity_Think(entity this)
        else this.alpha = 1;
 
     Weapon wep = this.owner.(weaponentity).m_weapon;
-       if (wep) this.glowmod = weaponentity_glowmod(wep, this.owner, this.owner.clientcolors);
+       if (wep) this.glowmod = weaponentity_glowmod(wep, this.owner, this.owner.clientcolors, this.owner.(weaponentity));
        this.colormap = this.owner.colormap;
 
        CSQCMODEL_AUTOUPDATE(this);