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;
WarpZone_FixView();
//WarpZone_FixPMove();
- {
- static string name_last;
- string name = get_weaponinfo(switchingweapon).mdl;
- if (name != name_last)
- {
- name_last = name;
- CL_WeaponEntity_SetModel(viewmodel, name);
- updateanim(viewmodel);
- if (!viewmodel.animstate_override)
- setanim(viewmodel, viewmodel.anim_idle, true, false, false);
- }
- }
vector ov_org = '0 0 0';
vector ov_mid = '0 0 0';
const int STAT_OK_AMMO_CHARGEPOOL = 86;
const int STAT_FROZEN = 87;
const int STAT_REVIVE_PROGRESS = 88;
-// 89 empty?
+const int STAT_WEAPON_NEXTTHINK = 89;
// 90 empty?
// 91 empty?
// 92 empty?
a.z = ReadCoord();
bool restartanim = ReadByte();
setanim(viewmodel, a, restartanim == false, restartanim, restartanim);
+ viewmodel.state = ReadByte();
}
#endif
#ifdef SVQC
-void wframe_send(entity actor, vector a, bool restartanim)
+void wframe_send(entity actor, .entity weaponentity, vector a, bool restartanim)
{
if (!IS_REAL_CLIENT(actor)) return;
int channel = MSG_ONE;
WriteCoord(channel, a.y);
WriteCoord(channel, a.z);
WriteByte(channel, restartanim);
+ WriteByte(channel, actor.(weaponentity).state);
}
#endif
return 0;
}
+// weapon states (actor.(weaponentity).state)
+/** no weapon selected */
+const int WS_CLEAR = 0;
+/** raise frame */
+const int WS_RAISE = 1;
+/** deselecting frame */
+const int WS_DROP = 2;
+/** fire state */
+const int WS_INUSE = 3;
+/** idle frame */
+const int WS_READY = 4;
+
.int ammo_shells;
.int ammo_nails;
.int ammo_rockets;
.void(Weapon thiswep, entity actor, .entity weaponentity, int fire) weapon_think;
-// weapon states (self.weaponentity.state)
-const int WS_CLEAR = 0; // no weapon selected
-const int WS_RAISE = 1; // raise frame
-const int WS_DROP = 2; // deselecting frame
-const int WS_INUSE = 3; // fire state
-const int WS_READY = 4; // idle frame
-
// there is 2 weapon tics that can run in one server frame
const int W_TICSPERFRAME = 2;
WepSet_AddStat_InMap();
addstat(STAT_SWITCHWEAPON, AS_INT, switchweapon);
addstat(STAT_SWITCHINGWEAPON, AS_INT, switchingweapon);
+ addstat(STAT_WEAPON_NEXTTHINK, AS_FLOAT, weapon_nextthink);
addstat(STAT_GAMESTARTTIME, AS_FLOAT, stat_game_starttime);
addstat(STAT_ROUNDSTARTTIME, AS_FLOAT, stat_round_starttime);
addstat(STAT_ALLOW_OLDVORTEXBEAM, AS_INT, stat_allow_oldvortexbeam);
this.weaponchild.colormap = this.colormap;
this.weaponchild.glowmod = this.glowmod;
}
-
- this.angles = '0 0 0';
-
- float f = this.owner.weapon_nextthink - time;
- if (this.state == WS_RAISE && !intermission_running)
- {
- entity newwep = Weapons_from(this.owner.switchweapon);
- f = f * g_weaponratefactor / max(f, newwep.switchdelay_raise);
- this.angles_x = -90 * f * f;
- }
- else if (this.state == WS_DROP && !intermission_running)
- {
- entity oldwep = Weapons_from(this.owner.weapon);
- f = 1 - f * g_weaponratefactor / max(f, oldwep.switchdelay_drop);
- this.angles_x = -90 * f * f;
- }
- else if (this.state == WS_CLEAR)
- {
- f = 1;
- this.angles_x = -90 * f * f;
- }
}
void CL_ExteriorWeaponentity_Think()
return false;
}
-void wframe_send(entity actor, vector a, bool restartanim);
+void wframe_send(entity actor, .entity weaponentity, vector a, bool restartanim);
void weapon_thinkf(entity actor, .entity weaponentity, float fr, float t, void(Weapon thiswep, entity actor,
.entity weaponentity, int fire) func)
else // if (fr == WFRAME_RELOAD)
a = actor.(weaponentity).anim_reload;
a.z *= g_weaponratefactor;
- wframe_send(actor, a, restartanim);
+ wframe_send(actor, weaponentity, a, restartanim);
}
v_forward = of;
actor.weapon_nextthink = time;
// dprint("reset weapon animation timer at ", ftos(time), "\n");
}
- actor.weapon_nextthink = actor.weapon_nextthink + t;
+ actor.weapon_nextthink += t;
actor.weapon_think = func;
// dprint("next ", ftos(actor.weapon_nextthink), "\n");