}
.vector viewmodel_origin, viewmodel_angles;
+.float weapon_nextthink;
+.float weapon_eta_last;
void viewmodel_draw(entity this)
{
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); // TODO: / W_WeaponRateFactor();
+ if (eta <= 0) f = this.weapon_eta_last;
+ else switch (this.state)
{
case WS_RAISE:
{
break;
}
}
+ this.weapon_eta_last = f;
this.origin = this.viewmodel_origin;
this.angles = this.viewmodel_angles;
this.angles_x = (-90 * f * f);
bool restartanim = ReadByte();
anim_set(viewmodel, a, !restartanim, restartanim, restartanim);
viewmodel.state = ReadByte();
+ viewmodel.weapon_nextthink = ReadFloat();
viewmodel.alpha = ReadByte() / 255;
return true;
}
WriteCoord(channel, a.z);
WriteByte(channel, restartanim);
WriteByte(channel, weaponentity.state);
+ WriteFloat(channel, weaponentity.weapon_nextthink);
WriteByte(channel, weaponentity.alpha * 255);
}
#endif
}
#define ReadFloat() ReadCoord()
- vector ReadVector() { vector v; v.x = ReadFloat(); v_y = ReadFloat(); v.z = ReadFloat(); return v; }
+ vector ReadVector() { vector v; v.x = ReadFloat(); v.y = ReadFloat(); v.z = ReadFloat(); return v; }
vector ReadVector2D() { vector v; v.x = ReadFloat(); v.y = ReadFloat(); v.z = 0; return v; }
float ReadApproxPastTime()
void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire);
void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire);
// VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
-.float weapon_nextthink = _STAT(WEAPON_NEXTTHINK);
+.float weapon_nextthink;
.void(Weapon thiswep, entity actor, .entity weaponentity, int fire) weapon_think;
vector or = v_right;
vector ou = v_up;
+ vector a = '0 0 0';
if (this)
{
this.wframe = fr;
- vector a = '0 0 0';
if (fr == WFRAME_IDLE) a = this.anim_idle;
else if (fr == WFRAME_FIRE1) a = this.anim_fire1;
else if (fr == WFRAME_FIRE2) a = this.anim_fire2;
else // if (fr == WFRAME_RELOAD)
a = this.anim_reload;
a.z *= g_weaponratefactor;
- entity e;
- FOR_EACH_CLIENT(e) if (e == actor || (IS_SPEC(e) && e.enemy == actor)) wframe_send(e, this, a, restartanim);
}
v_forward = of;
// dprint("reset weapon animation timer at ", ftos(time), "\n");
}
this.weapon_nextthink += t;
- if (weaponentity == weaponentities[0]) actor.weapon_nextthink = this.weapon_nextthink;
+ if (weaponentity == weaponentities[0]) STAT(WEAPON_NEXTTHINK, actor) = this.weapon_nextthink;
this.weapon_think = func;
// dprint("next ", ftos(this.weapon_nextthink), "\n");
+ if (this)
+ {
+ entity e;
+ FOR_EACH_CLIENT(e) if (e == actor || (IS_SPEC(e) && e.enemy == actor)) wframe_send(e, this, a, restartanim);
+ }
+
if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
{
- if ((actor.weapon == WEP_SHOCKWAVE.m_id || actor.weapon == WEP_SHOTGUN.m_id)
- && fr == WFRAME_FIRE2) animdecide_setaction(actor, ANIMACTION_MELEE, restartanim);
- else animdecide_setaction(actor, ANIMACTION_SHOOT, restartanim);
+ int act = (fr == WFRAME_FIRE2 && (actor.weapon == WEP_SHOCKWAVE.m_id || actor.weapon == WEP_SHOTGUN.m_id))
+ ? ANIMACTION_MELEE
+ : ANIMACTION_SHOOT
+ ;
+ animdecide_setaction(actor, act, restartanim);
}
- else
+ else if (actor.anim_upper_action == ANIMACTION_SHOOT || actor.anim_upper_action == ANIMACTION_MELEE)
{
- if (actor.anim_upper_action == ANIMACTION_SHOOT
- || actor.anim_upper_action == ANIMACTION_MELEE) actor.anim_upper_action = 0;
+ actor.anim_upper_action = 0;
}
}
entity oldwep = Weapons_from(actor.weapon);
// set up weapon switch think in the future, and start drop anim
- if (
-#if INDEPENDENT_ATTACK_FINISHED
- true
-#else
- ATTACK_FINISHED(actor, slot) <= time + actor.weapon_frametime * 0.5
-#endif
- )
+ if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + actor.weapon_frametime * 0.5)
{
sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
this.state = WS_DROP;