#include "mutators/events.qh"
+#include "../common/anim.qh"
#include "../common/constants.qh"
#include "../common/debug.qh"
#include "../common/mapinfo.qh"
#include "../lib/warpzone/client.qh"
#include "../lib/warpzone/common.qh"
+#define EFMASK_CHEAP (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NODRAW | EF_NOSHADOW | EF_SELECTABLE | EF_TELEPORT_BIT)
+
+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;
+ entity me = CSQCModel_server2csqc(player_localentnum);
+ int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
+ | EF_NODEPTHTEST)
+ &~ (EF_FULLBRIGHT); // can mask team color, so get rid of it
+ for (entity e = this; e; e = e.weaponchild)
+ {
+ e.drawmask = mask;
+ e.alpha = a;
+ e.colormap = c;
+ e.glowmod = g;
+ e.csqcmodel_effects = fx;
+ WITH(entity, self, e, CSQCModel_Effects_Apply());
+ }
+ {
+ static string name_last;
+ string name = get_weaponinfo(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);
+ }
+ }
+ float eta = (getstatf(STAT_WEAPON_NEXTTHINK) - time); // TODO: / W_WeaponRateFactor();
+ float f = 0; // 0..1; 0: fully active
+ switch (this.state)
+ {
+ case WS_RAISE:
+ {
+ // entity newwep = Weapons_from(activeweapon);
+ float delay = 0.2; // TODO: newwep.switchdelay_raise;
+ f = eta / max(eta, delay);
+ this.angles_x = -90 * f * f;
+ break;
+ }
+ case WS_DROP:
+ {
+ // entity oldwep = Weapons_from(activeweapon);
+ float delay = 0.2; // TODO: newwep.switchdelay_drop;
+ f = 1 - eta / max(eta, delay);
+ this.angles_x = -90 * f * f;
+ break;
+ }
+ case WS_CLEAR:
+ {
+ f = 1;
+ break;
+ }
+ }
+ this.angles_x = -90 * f * f;
+}
+
+entity viewmodel;
+STATIC_INIT(viewmodel) {
+ viewmodel = new(viewmodel);
+ viewmodel.draw = viewmodel_draw;
+}
+
entity porto;
vector polyline[16];
void Porto_Draw(entity this)