From: TimePath Date: Mon, 2 Nov 2015 06:38:13 +0000 (+1100) Subject: Viewmodel: network alpha and glowmod (for vortex) X-Git-Tag: xonotic-v0.8.2~1601^2~17 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6c222172fcdafa3cf72ee48b7d3cc11a55ece962;p=xonotic%2Fxonotic-data.pk3dir.git Viewmodel: network alpha and glowmod (for vortex) --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index dcd9d7ecc..0e7ec4aa4 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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; diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 11f0414e6..854fa93a0 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -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 diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index e8c5d2cd3..6746627ab 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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(); } diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 395834ef0..189a619e5 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -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; } }