entity e = spawn();
setthink(e, lms_extralife);
+ Item_CopyFields(ent, e);
+
e.nextthink = time + 0.1;
- e.spawnflags = ent.spawnflags;
- e.noalign = ent.noalign;
- setorigin(e, ent.origin);
return true;
}
void replace_with_insta_cells(entity item)
{
entity e = new(item_vaporizer_cells);
- setorigin(e, item.origin);
- e.noalign = Item_ShouldKeepPosition(item);
- e.cnt = item.cnt;
- e.team = item.team;
- e.spawnfunc_checked = true;
+ Item_CopyFields(item, e);
spawnfunc_item_vaporizer_cells(e);
}
setthink(e, instagib_speed);
}
+ Item_CopyFields(ent, e);
e.nextthink = time + 0.1;
- e.spawnflags = ent.spawnflags;
- e.noalign = ent.noalign;
- setorigin(e, ent.origin);
return true;
}
if (item.classname == "item_strength")
{
entity wep = new(weapon_okhmg);
- setorigin(wep, item.origin);
+ Item_CopyFields(item, wep);
wep.ok_item = true;
- wep.noalign = Item_ShouldKeepPosition(item);
- wep.cnt = item.cnt;
- wep.team = item.team;
wep.respawntime = g_pickup_respawntime_superweapon;
wep.pickup_anyway = true;
- wep.spawnfunc_checked = true;
Item_Initialize(wep, "weapon_okhmg"); // doesn't actually use spawnfunc
return true;
}
else if (item.classname == "item_shield")
{
entity wep = new(weapon_okrpc);
- setorigin(wep, item.origin);
+ Item_CopyFields(item, wep);
wep.ok_item = true;
- wep.noalign = Item_ShouldKeepPosition(item);
- wep.cnt = item.cnt;
- wep.team = item.team;
wep.respawntime = g_pickup_respawntime_superweapon;
wep.pickup_anyway = true;
- wep.spawnfunc_checked = true;
Item_Initialize(wep, "weapon_okrpc"); // doesn't actually use spawnfunc
return true;
}
entity new_item;
if (!MUTATOR_IS_ENABLED(ok))
{
+ // TODO: doesn't copy many fields from items
new_item = Item_Create(strzone(new_classname), item.origin,
Item_ShouldKeepPosition(item));
random_items_is_spawning = false;
else
{
new_item = spawn();
+ Item_CopyFields(item, new_item);
new_item.classname = strzone(new_classname);
- new_item.spawnfunc_checked = true;
- new_item.noalign = Item_ShouldKeepPosition(item);
new_item.ok_item = true;
Item_Initialize(new_item, new_classname);
random_items_is_spawning = false;
{
return NULL;
}
- setorigin(new_item, item.origin);
}
if (item.team)
{
});
}
+void Item_CopyFields(entity this, entity to)
+{
+ setorigin(to, this.origin);
+ to.spawnflags = this.spawnflags;
+ to.noalign = Item_ShouldKeepPosition(this);
+ to.cnt = this.cnt;
+ to.team = this.team;
+ to.spawnfunc_checked = true;
+ // TODO: copy respawn times? this may not be desirable in some cases
+ //to.respawntime = this.respawntime;
+ //to.respawntimejitter = this.respawntimejitter;
+}
+
// Savage: used for item garbage-collection
void RemoveItem(entity this)
{
void Item_FindTeam(entity this);
+void Item_CopyFields(entity this, entity to);
+
bool ItemSend(entity this, entity to, int sf);
void ItemUpdate(entity this);
if(wep != WEP_Null)
{
entity replacement = spawn();
- copyentity(this, replacement);
+ Item_CopyFields(this, replacement);
+ // DO NOT USE, causes #2792
+ //copyentity(this, replacement);
replacement.m_isreplaced = true;
weapon_defaultspawnfunc(replacement, wep);
}