setorigin(wep, ent.origin);
setmodel(wep, MDL_OK_HMG);
wep.ok_item = true;
- wep.noalign = ent.noalign;
+ wep.noalign = Item_ShouldKeepPosition(ent);
wep.cnt = ent.cnt;
wep.team = ent.team;
wep.respawntime = g_pickup_respawntime_superweapon;
setorigin(wep, ent.origin);
setmodel(wep, MDL_OK_RPC);
wep.ok_item = true;
- wep.noalign = ent.noalign;
+ wep.noalign = Item_ShouldKeepPosition(ent);
wep.cnt = ent.cnt;
wep.team = ent.team;
wep.respawntime = g_pickup_respawntime_superweapon;
if (!expr_evaluate(autocvar_g_overkill))
{
new_item = Item_Create(strzone(new_classname), item.origin,
- item.noalign);
+ Item_ShouldKeepPosition(item));
random_items_is_spawning = false;
if (new_item == NULL)
{
new_item = spawn();
new_item.classname = strzone(new_classname);
new_item.spawnfunc_checked = true;
- new_item.noalign = item.noalign;
+ new_item.noalign = Item_ShouldKeepPosition(item);
new_item.ok_item = true;
Item_Initialize(new_item, new_classname);
random_items_is_spawning = false;
_Movetype_CheckWater(this);
this.origin = this.origin + movedt * this.velocity;
this.angles = this.angles + movedt * this.avelocity;
- _Movetype_LinkEdict(this, false);
break;
case MOVETYPE_STEP:
_Movetype_Physics_Step(this, movedt);
case MOVETYPE_PHYSICS:
break;
}
+
+ //_Movetype_CheckVelocity(this);
+
+ _Movetype_LinkEdict(this, true);
+
+ //_Movetype_CheckVelocity(this);
}
void Movetype_Physics_NoMatchTicrate(entity this, float movedt, bool isclient) // to be run every move frame
if(autocvar_g_antilag == 0 || noantilag)
lag = 0; // only do hitscan, but no antilag
if(lag)
- {
- FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_takeback(it, CS(it), time - lag));
- IL_EACH(g_monsters, it != actor,
- {
- antilag_takeback(it, it, time - lag);
- });
- }
+ antilag_takeback_all(actor, lag);
while(head)
{
}
if(lag)
- {
- FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_restore(it, CS(it)));
- IL_EACH(g_monsters, it != actor,
- {
- antilag_restore(it, it);
- });
- }
+ antilag_restore_all(actor);
}
METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
}
store.antilag_index = ANTILAG_MAX_ORIGINS - 1; // next one is 0
}
+
+// TODO: use a single intrusive list across all antilagged entities
+void antilag_takeback_all(entity ignore, float lag)
+{
+ FOREACH_CLIENT(IS_PLAYER(it) && it != ignore, antilag_takeback(it, CS(it), time - lag));
+ IL_EACH(g_monsters, it != ignore,
+ {
+ antilag_takeback(it, it, time - lag);
+ });
+ IL_EACH(g_projectiles, it != ignore && it.classname == "nade",
+ {
+ antilag_takeback(it, it, time - lag);
+ });
+}
+
+void antilag_restore_all(entity ignore)
+{
+ FOREACH_CLIENT(IS_PLAYER(it) && it != ignore, antilag_restore(it, CS(it)));
+ IL_EACH(g_monsters, it != ignore,
+ {
+ antilag_restore(it, it);
+ });
+ IL_EACH(g_projectiles, it != ignore && it.classname == "nade",
+ {
+ antilag_restore(it, it);
+ });
+}
void antilag_restore(entity e, entity store);
void antilag_clear(entity e, entity store);
+void antilag_takeback_all(entity ignore, float lag);
+void antilag_restore_all(entity ignore);
+
.float antilag_debug;
#define ANTILAG_LATENCY(e) min(0.4, CS(e).ping * 0.001)
{
IL_EACH(g_items, it.targetname == this.target,
{
- if (it.classname == "weapon_rocketlauncher" || it.classname == "weapon_devastator") {
+ if (it.classname == "weapon_devastator") {
this.ammo_rockets += it.count * WEP_CVAR(devastator, ammo);
this.netname = cons(this.netname, "devastator");
}
- else if (it.classname == "weapon_railgun") {
+ else if (it.classname == "weapon_vortex") {
this.ammo_cells += it.count * WEP_CVAR_PRI(vortex, ammo); // WEAPONTODO
this.netname = cons(this.netname, "vortex");
}
- else if (it.classname == "weapon_lightning") {
+ else if (it.classname == "weapon_electro") {
this.ammo_cells += it.count * WEP_CVAR_PRI(electro, ammo); // WEAPONTODO
this.netname = cons(this.netname, "electro");
}
- else if (it.classname == "weapon_plasmagun") {
+ else if (it.classname == "weapon_hagar") {
this.ammo_rockets += it.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
this.netname = cons(this.netname, "hagar");
}
- else if (it.classname == "weapon_bfg") {
+ else if (it.classname == "weapon_crylink") {
this.ammo_cells += it.count * WEP_CVAR_PRI(crylink, ammo);
this.netname = cons(this.netname, "crylink");
}
- else if (it.classname == "weapon_grenadelauncher" || it.classname == "weapon_mortar") {
+ else if (it.classname == "weapon_mortar") {
this.ammo_rockets += it.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
this.netname = cons(this.netname, "mortar");
}
- else if (it.classname == "item_armor_body")
+ else if (it.classname == "item_armor_mega")
this.armorvalue = 100;
else if (it.classname == "item_health_mega")
this.health = 200;
source.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
if (lag)
- {
- // take players back into the past
- FOREACH_CLIENT(IS_PLAYER(it) && it != forent, antilag_takeback(it, CS(it), time - lag));
- IL_EACH(g_monsters, it != forent,
- {
- antilag_takeback(it, it, time - lag);
- });
- }
+ antilag_takeback_all(forent, lag);
// do the trace
if(wz)
// restore players to current positions
if (lag)
- {
- FOREACH_CLIENT(IS_PLAYER(it) && it != forent, antilag_restore(it, CS(it)));
- IL_EACH(g_monsters, it != forent,
- {
- antilag_restore(it, it);
- });
- }
+ antilag_restore_all(forent);
// restore shooter solid type
if(source)
{
antilag_record(it, it, altime);
});
+ IL_EACH(g_projectiles, it.classname == "nade",
+ {
+ antilag_record(it, it, altime);
+ });
systems_update();
IL_ENDFRAME();
}
item.m_isloot = loot;
}
+bool Item_ShouldKeepPosition(entity item)
+{
+ return item.noalign || (item.spawnflags & 1);
+}
+
bool Item_IsExpiring(entity item)
{
return item.m_isexpiring;
/// \return No return.
void Item_SetLoot(entity item, bool loot);
+/// \brief Returns whether item should keep its position or be dropped to the
+/// ground.
+/// \param[in] item Item to check.
+/// \return True if item should keep its position or false if it should be
+/// dropped to the ground.
+bool Item_ShouldKeepPosition(entity item);
+
/// \brief Returns whether the item is expiring (i.e. its strength, shield and
/// superweapon timers expire while it is on the ground).
/// \param[in] item Item to check.
if(autocvar_g_antilag == 0 || noantilag)
lag = 0; // only do hitscan, but no antilag
if(lag)
- {
- FOREACH_CLIENT(IS_PLAYER(it) && it != this, antilag_takeback(it, CS(it), time - lag));
- IL_EACH(g_monsters, it != this,
- {
- antilag_takeback(it, it, time - lag);
- });
- }
+ antilag_takeback_all(this, lag);
// change shooter to SOLID_BBOX so the shot can hit corpses
int oldsolid = this.dphitcontentsmask;
}
if(lag)
- {
- FOREACH_CLIENT(IS_PLAYER(it) && it != this, antilag_restore(it, CS(it)));
- IL_EACH(g_monsters, it != this,
- {
- antilag_restore(it, it);
- });
- }
+ antilag_restore_all(this);
// restore shooter solid type
if(this)