t *= 5;
}
bspeed = xyspeed * 0.01;
- MAKEVECTORS(makevectors, gunangles, forward, right, up);
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
float bobr = bspeed * autocvar_cl_bobmodel_side * autocvar_cl_viewmodel_scale * sin(s) * t;
gunorg += bobr * right;
float bobu = bspeed * autocvar_cl_bobmodel_up * autocvar_cl_viewmodel_scale * cos(s * 2) * t;
gunorg += bobu * up;
}
- this.origin += view_forward * gunorg.x + view_right * gunorg.y + view_up * gunorg.z;
+ vector v = rotate(gunorg, YAW(view_angles) * DEG2RAD); // rotate world coordinates to relative ones
+ v.z = gunorg.z;
+ this.origin += v;
gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
this.angles += gunangles;
}
.vector viewmodel_origin, viewmodel_angles;
+.float weapon_nextthink;
+.float weapon_eta_last;
+.float weapon_switchdelay;
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(activeweapon);
+ 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)
{
e.drawmask = mask;
e.alpha = a;
- e.colormap = c;
+ e.colormap = 256 + c; // colormap == 0 is black, c == 0 is white
e.glowmod = g;
e.csqcmodel_effects = fx;
WITH(entity, self, e, CSQCModel_Effects_Apply());
if (!this.animstate_override)
anim_set(this, this.anim_idle, true, false, false);
}
- float eta = (STAT(WEAPON_NEXTTHINK) - time); // TODO: / W_WeaponRateFactor();
float f = 0; // 0..1; 0: fully active
- switch (this.state)
+ float eta = (this.weapon_nextthink - time) / STAT(WEAPONRATEFACTOR);
+ if (eta <= 0) f = this.weapon_eta_last;
+ else switch (this.state)
{
case WS_RAISE:
{
- // entity newwep = Weapons_from(activeweapon);
- float delay = 0.2; // TODO: newwep.switchdelay_raise;
- f = eta / max(eta, delay);
+ f = eta / max(eta, this.weapon_switchdelay);
break;
}
case WS_DROP:
{
- // entity oldwep = Weapons_from(activeweapon);
- float delay = 0.2; // TODO: newwep.switchdelay_drop;
- f = 1 - eta / max(eta, delay);
+ f = 1 - eta / max(eta, this.weapon_switchdelay);
break;
}
case WS_CLEAR:
break;
}
}
+ this.weapon_eta_last = f;
this.origin = this.viewmodel_origin;
this.angles = this.viewmodel_angles;
this.angles_x = (-90 * f * f);
return SHOTTYPE_HITWORLD;
if(n > maxclients)
return SHOTTYPE_HITWORLD;
- t = GetPlayerColor(n - 1);
+ t = entcs_GetTeam(n - 1);
if(teamplay)
if(t == myteam)
return SHOTTYPE_HITTEAM;
current_player = player_localentnum - 1;
else // then player_localentnum is the vehicle I'm driving
current_player = player_localnum;
- myteam = GetPlayerColor(current_player);
+ myteam = entcs_GetTeam(current_player);
if(myteam != prev_myteam)
{