]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Viewmodels: clientside Vortex glow
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 29 Nov 2015 23:58:59 +0000 (10:58 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 29 Nov 2015 23:58:59 +0000 (10:58 +1100)
qcsrc/client/view.qc
qcsrc/common/stats.qh
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_client.qh

index a6d05d9a62cd24ca8a9ea2f15f75b353b79feb55..07fa43eddd18a6a032405fa363e4e05f592523dd 100644 (file)
@@ -270,7 +270,9 @@ void viewmodel_draw(entity this)
        int mask = (intermission || (getstati(STAT_HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
        float a = this.alpha;
        int c = stof(getplayerkeyvalue(current_player, "colors"));
-       vector g = this.glowmod; // TODO: completely clientside: colormapPaletteColor(c & 0x0F, true) * 2;
+       vector g;
+       Weapon wep = Weapons_from(switchingweapon);
+       if (!(g = wep.wr_glow(wep))) g = colormapPaletteColor(c & 0x0F, true) * 2;
        entity me = CSQCModel_server2csqc(player_localentnum - 1);
        int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
                | EF_NODEPTHTEST)
index be3e10f5ef1bd1e06fdac0591ce4393d8fe41e67..5b25997948215433a1a35b46a06f3ffec919461c 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef STATS_H
 #define STATS_H
 
+#ifdef SVQC
+#include "../server/cl_client.qh"
+#endif
+
 // Full list of all stat constants, included in a single location for easy reference
 // 255 is the current limit (MAX_CL_STATS - 1), engine will need to be modified if you wish to add more stats
 
@@ -36,6 +40,9 @@ REGISTER_STAT(SWITCHWEAPON, int)
 /** weapon currently being switched to (is copied from switchweapon once switch is possible) */
 REGISTER_STAT(SWITCHINGWEAPON, int)
 REGISTER_STAT(WEAPON_NEXTTHINK, float)
+#ifdef SVQC
+SPECTATE_COPY(_STAT(WEAPON_NEXTTHINK))
+#endif
 
 REGISTER_STAT(GAMESTARTTIME, float)
 REGISTER_STAT(STRENGTH_FINISHED, float)
index 849403f8713740773c0c7d780b6213b073064f96..f0b606e8b1b9ddc6437ae514ccc8deb62fe351de 100644 (file)
@@ -582,32 +582,6 @@ void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim)
 }
 #endif
 
-REGISTER_NET_TEMP(wglow)
-#ifdef CSQC
-NET_HANDLE(wglow, bool isNew)
-{
-       vector g = '0 0 0';
-       g.x = ReadCoord();
-       g.y = ReadCoord();
-       g.z = ReadCoord();
-       viewmodel.glowmod = g;
-       return true;
-}
-#endif
-
-#ifdef SVQC
-void wglow_send(entity actor, vector g)
-{
-       if (!IS_REAL_CLIENT(actor)) return;
-       int channel = MSG_ONE;
-       msg_entity = actor;
-       WriteHeader(channel, wglow);
-       WriteCoord(channel, g.x);
-       WriteCoord(channel, g.y);
-       WriteCoord(channel, g.z);
-}
-#endif
-
 #endif
 
 #endif
index 71e121f81201ea0b39504c46a63ed72290b0ddfd..3f09e914a6e23db8741b12d9f150977a07302a10 100644 (file)
@@ -118,6 +118,8 @@ CLASS(Weapon, Object)
         // no weapon specific image for this weapon
         return false;
     }
+    /** (CLIENT) weapon specific glow */
+    METHOD(Weapon, wr_glow, vector(Weapon this)) { return '0 0 0'; }
     /** (SERVER) the weapon is dropped */
     METHOD(Weapon, wr_drop, void(Weapon this)) {}
     /** (SERVER) a weapon is picked up */
index ad8c6600d8edc11d1526114efa3733a37fe31276..a3caf7aabce3550602f084d95698efca28b5c574 100644 (file)
@@ -61,6 +61,37 @@ VORTEX_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #ifdef IMPLEMENTATION
 
+REGISTER_STAT(WEP_CVAR_vortex_charge, bool, WEP_CVAR(vortex, charge))
+REGISTER_STAT(WEP_CVAR_vortex_charge_animlimit, float, WEP_CVAR(vortex, charge_animlimit))
+
+#if defined(CSQC)
+float autocvar_g_weapon_charge_colormod_red_full;
+float autocvar_g_weapon_charge_colormod_red_half;
+float autocvar_g_weapon_charge_colormod_green_full;
+float autocvar_g_weapon_charge_colormod_blue_full;
+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))
+{
+       if (!STAT(WEP_CVAR_vortex_charge)) return '0 0 0';
+       float charge = STAT(VORTEX_CHARGE);
+       float animlimit = STAT(WEP_CVAR_vortex_charge_animlimit);
+       vector g;
+       g.x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, charge / animlimit);
+       g.y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, charge / animlimit);
+       g.z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, charge / animlimit);
+       if (charge > animlimit)
+       {
+               g.x += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (charge - animlimit) / (1 - animlimit);
+               g.y += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (charge - animlimit) / (1 - animlimit);
+               g.z += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (charge - animlimit) / (1 - animlimit);
+       }
+       return g;
+}
+#endif
+
 REGISTER_NET_TEMP(TE_CSQC_VORTEXBEAMPARTICLE)
 
 #if defined(SVQC)
index 623b5f7662e7545f60a1f72f639e87eed99a32c1..e4220f5d0c7f174d39befa55a55bd9f3710cc8b9 100644 (file)
@@ -296,13 +296,6 @@ bool autocvar_g_use_ammunition;
 bool autocvar_g_waypointeditor;
 int autocvar_g_waypointeditor_auto;
 bool autocvar_g_waypoints_for_items;
-float autocvar_g_weapon_charge_colormod_blue_full;
-float autocvar_g_weapon_charge_colormod_blue_half;
-float autocvar_g_weapon_charge_colormod_green_full;
-float autocvar_g_weapon_charge_colormod_green_half;
-float autocvar_g_weapon_charge_colormod_hdrmultiplier;
-float autocvar_g_weapon_charge_colormod_red_full;
-float autocvar_g_weapon_charge_colormod_red_half;
 #define autocvar_g_weapon_stay cvar("g_weapon_stay")
 bool autocvar_g_weapon_throwable;
 #define autocvar_g_weaponarena cvar_string("g_weaponarena")
index 0cc6a0b65d745e6a0b784ecbf3fa362714df8a5e..e1b34a9bb9c91e3ad26a08937a10b31974bb2778 100644 (file)
@@ -1664,8 +1664,8 @@ spectate mode routines
 ======================
 */
 
-void SpectateCopy(entity spectatee)
-{SELFPARAM();
+void SpectateCopy(entity this, entity spectatee)
+{
        MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
        self.armortype = spectatee.armortype;
        self.armorvalue = spectatee.armorvalue;
@@ -1690,7 +1690,6 @@ void SpectateCopy(entity spectatee)
        self.switchweapon = spectatee.switchweapon;
        self.switchingweapon = spectatee.switchingweapon;
        self.weapon = spectatee.weapon;
-       self.weapon_nextthink = spectatee.weapon_nextthink;
        self.vortex_charge = spectatee.vortex_charge;
        self.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
        self.hagar_load = spectatee.hagar_load;
@@ -1751,7 +1750,7 @@ bool SpectateUpdate()
                return false;
        }
 
-       SpectateCopy(self.enemy);
+       SpectateCopy(this, this.enemy);
 
        return true;
 }
@@ -2148,8 +2147,6 @@ void PlayerUseKey()
 }
 
 
-void wglow_send(entity actor, vector g);
-
 /*
 =============
 PlayerPreThink
@@ -2325,28 +2322,6 @@ void PlayerPreThink ()
 
                if(frametime)
                {
-                       vector g;
-                       if (IS_SPEC(self))
-                       {
-                               g = self.enemy.weaponentity_glowmod;
-                       }
-                       else if(self.weapon == WEP_VORTEX.m_id && WEP_CVAR(vortex, charge))
-                       {
-                               g.x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
-                               g.y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
-                               g.z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
-
-                               if(self.vortex_charge > WEP_CVAR(vortex, charge_animlimit))
-                               {
-                                       g.x += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
-                                       g.y += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
-                                       g.z += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
-                               }
-                       }
-                       else
-                               g = colormapPaletteColor(self.clientcolors & 0x0F, true) * 2;
-                       if (g != self.weaponentity_glowmod)
-                               wglow_send(self, self.weaponentity_glowmod = g);
                        player_powerups();
                }
 
index 1b462a329538ab3c6527a43b187a08f416d28804..a0dfd72f8218722b3c8858e71a8b7b3c3f7bb5c5 100644 (file)
@@ -8,4 +8,6 @@ float CalcRotRegen(float current, float regenstable, float regenfactor, float re
 
 float Spectate(entity pl);
 
+#define SPECTATE_COPY(fld) [[accumulate]] void SpectateCopy(entity this, entity spectatee) { this.(fld) = spectatee.(fld); }
+
 #endif