}
}
+.float old_movetype;
void sandbox_ObjectAttach_Remove(entity e);
void sandbox_ObjectAttach_Set(entity e, entity parent, string s)
{
// we can't attach to an attachment, for obvious reasons
sandbox_ObjectAttach_Remove(e);
+ e.old_movetype = e.movetype; // persist physics
e.movetype = MOVETYPE_FOLLOW;
e.solid = SOLID_NOT;
e.takedamage = DAMAGE_NO;
if(head.owner == e)
{
vector org;
- head.movetype = MOVETYPE_TOSS; // default
+ head.movetype = head.old_movetype; // restore persisted physics
head.solid = SOLID_BBOX;
head.takedamage = DAMAGE_AIM;
for(head = world; (head = find(head, classname, "object")); )
{
// the main object needs to be first in the array [0] with attached objects following
- float slot;
- string tagindex;
+ float slot, physics;
+ string tagname;
if(head == e) // this is the main object, place it first
{
slot = 0;
- tagindex = string_null; // the main object is not attached to anything
+ physics = head.movetype; // applied physics are normal physics for parents
}
else if(head.owner == e) // child object, list them in order
{
i += 1; // children start from 1
slot = i;
+ physics = head.old_movetype; // persisted physics are normal physics for children
// get the name of the tag our object is attached to
gettaginfo(head.owner, head.tag_index);
- tagindex = gettaginfo_name;
+ tagname = gettaginfo_name;
}
else
continue;
if(slot)
{
// properties stored only for child objects
- if(tagindex) port_string[slot] = strcat(port_string[slot], "\"", tagindex, "\" "); else port_string[slot] = strcat(port_string[slot], "- "); // none
+ if(tagname) port_string[slot] = strcat(port_string[slot], "\"", tagname, "\" "); else port_string[slot] = strcat(port_string[slot], "- "); // none
}
else
{
port_string[slot] = strcat(port_string[slot], sprintf("\"%.9v\"", head.glowmod), " ");
port_string[slot] = strcat(port_string[slot], ftos(head.frame), " ");
port_string[slot] = strcat(port_string[slot], ftos(head.scale), " ");
- port_string[slot] = strcat(port_string[slot], ftos(head.movetype), " ");
+ port_string[slot] = strcat(port_string[slot], ftos(physics), " ");
port_string[slot] = strcat(port_string[slot], ftos(head.damageforcescale), " ");
if(head.material) port_string[slot] = strcat(port_string[slot], "\"", head.material, "\" "); else port_string[slot] = strcat(port_string[slot], "- "); // none
if(database)
for(i = 0; i < n; ++i)
{
float argv_num;
+ string tagname;
argv_num = 0;
tokenize_console(port_string[i]);
e = sandbox_ObjectSpawn(database);
if(i)
{
// properties stored only for child objects
- if(argv(argv_num) != "-") sandbox_ObjectAttach_Set(e, parent, argv(argv_num)); else sandbox_ObjectAttach_Set(e, parent, ""); ++argv_num;
+ if(argv(argv_num) != "-") tagname = argv(argv_num); else tagname = string_null; ++argv_num;
}
else
{
e.glowmod = stov(argv(argv_num)); ++argv_num;
e.frame = stof(argv(argv_num)); ++argv_num;
sandbox_ObjectEdit_Scale(e, stof(argv(argv_num))); ++argv_num;
- e.movetype = stof(argv(argv_num)); ++argv_num;
+ e.movetype = e.old_movetype = stof(argv(argv_num)); ++argv_num;
e.damageforcescale = stof(argv(argv_num)); ++argv_num;
if(e.material) strunzone(e.material); if(argv(argv_num) != "-") e.material = strzone(argv(argv_num)); else e.material = string_null; ++argv_num;
if(database)
// properties stored only for the database
if(e.crypto_idfp) strunzone(e.crypto_idfp); if(argv(argv_num) != "-") e.crypto_idfp = strzone(argv(argv_num)); else e.crypto_idfp = string_null; ++argv_num;
}
+
+ // attach last
+ sandbox_ObjectAttach_Set(e, parent, tagname);
}
for(i = 0; i <= MAX_STORAGE_ATTACHMENTS; ++i)