]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Viewmodel: network alpha and glowmod (for vortex)
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 2 Nov 2015 06:38:13 +0000 (17:38 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 2 Nov 2015 06:38:13 +0000 (17:38 +1100)
qcsrc/client/view.qc
qcsrc/common/weapons/all.qc
qcsrc/server/cl_client.qc
qcsrc/server/weapons/weaponsystem.qc

index dcd9d7ecc7cf688755df462f149b3a892cf4d46b..0e7ec4aa421ceffe18bb181a87e03205e46125d2 100644 (file)
@@ -35,8 +35,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 = colormapPaletteColor(c & 0x0F, true) * 2;
+       vector g = this.glowmod; // TODO: completely clientside: colormapPaletteColor(c & 0x0F, true) * 2;
        entity me = CSQCModel_server2csqc(player_localentnum);
        int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
                | EF_NODEPTHTEST)
@@ -44,6 +45,7 @@ void viewmodel_draw(entity this)
        for (entity e = this; e; e = e.weaponchild)
        {
                e.drawmask = mask;
+               e.alpha = a;
                e.colormap = c;
                e.glowmod = g;
                e.csqcmodel_effects = fx;
index 11f0414e63d9b13b1957273ef51cebbfdd16ba21..854fa93a09816447aa6bf13d1c9b8798803099fb 100644 (file)
@@ -592,6 +592,7 @@ REGISTER_NET_TEMP(wframe, bool isNew)
        bool restartanim = ReadByte();
        setanim(viewmodel, a, restartanim == false, restartanim, restartanim);
        viewmodel.state = ReadByte();
+       viewmodel.alpha = ReadByte() / 255;
 }
 #endif
 
@@ -607,6 +608,31 @@ void wframe_send(entity actor, .entity weaponentity, vector a, bool restartanim)
        WriteCoord(channel, a.z);
        WriteByte(channel, restartanim);
        WriteByte(channel, actor.(weaponentity).state);
+       WriteByte(channel, actor.(weaponentity).alpha * 255);
+}
+#endif
+
+REGISTER_NET_TEMP(wglow, bool isNew)
+#ifdef CSQC
+{
+       vector g = '0 0 0';
+       g.x = ReadCoord();
+       g.y = ReadCoord();
+       g.z = ReadCoord();
+       viewmodel.glowmod = g;
+}
+#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
 
index e8c5d2cd3a5229fe2d45d6131f24c0d6df8cbf39..6746627ab55c21fb6b82d3af82c52cec3852ebd0 100644 (file)
@@ -2164,6 +2164,8 @@ float isInvisibleString(string s)
        return true;
 }
 
+void wglow_send(entity actor, vector g);
+
 /*
 =============
 PlayerPreThink
@@ -2339,22 +2341,24 @@ void PlayerPreThink (void)
 
                if(frametime)
                {
+                       vector g;
                        if(self.weapon == WEP_VORTEX.m_id && WEP_CVAR(vortex, charge))
                        {
-                               self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
-                               self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
-                               self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
+                               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))
                                {
-                                       self.weaponentity_glowmod_x = self.weaponentity_glowmod.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));
-                                       self.weaponentity_glowmod_y = self.weaponentity_glowmod.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));
-                                       self.weaponentity_glowmod_z = self.weaponentity_glowmod.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));
+                                       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
-                               self.weaponentity_glowmod = colormapPaletteColor(self.clientcolors & 0x0F, true) * 2;
-
+                               g = colormapPaletteColor(self.clientcolors & 0x0F, true) * 2;
+                       if (g != self.weaponentity_glowmod)
+                               wglow_send(self, self.weaponentity_glowmod = g);
                        player_powerups();
                }
 
index 395834ef0617f74f844c3ea53d41b61985b92aed..189a619e57279fe18711da60fb4028fb2aebd7ab 100644 (file)
@@ -93,31 +93,15 @@ void CL_Weaponentity_Think()
                CL_WeaponEntity_SetModel(this, this.owner.weaponname);
        }
 
-       int tb = (this.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT));
-       this.effects = this.owner.effects
-           & EFMASK_CHEAP
-           & ~(
-           EF_LOWPRECISION
-           | EF_FULLBRIGHT  // can mask team color, so get rid of it
-           | EF_TELEPORT_BIT
-           | EF_RESTARTANIM_BIT
-              )
-           | tb
-           // TODO: don't render this entity at all
-           | EF_NODRAW;
+       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;
 
-       this.glowmod = this.owner.weaponentity_glowmod;
-       this.colormap = this.owner.colormap;
        if (this.weaponchild)
        {
                this.weaponchild.effects = this.effects;
-               this.weaponchild.alpha = this.alpha;
-               this.weaponchild.colormap = this.colormap;
-               this.weaponchild.glowmod = this.glowmod;
        }
 }