From: Mircea Kitsune Date: Sun, 4 Dec 2011 15:47:17 +0000 (+0200) Subject: Allow setting and persisting the solidity of objects. I will use a dirty but necessar... X-Git-Tag: xonotic-v0.6.0~35^2~15^2~13 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f52e3fb42250bfd82afa1689625922b26a7739eb;p=xonotic%2Fxonotic-data.pk3dir.git Allow setting and persisting the solidity of objects. I will use a dirty but necessary hack to make non-solid objects traceable. Note that this change breaks previous storages. --- diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 6514dccba..52bbd354b 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -89,7 +89,7 @@ void sandbox_ObjectEdit_Scale(entity e, float f) } } -.float old_movetype; +.float old_solid, old_movetype; void sandbox_ObjectAttach_Remove(entity e); void sandbox_ObjectAttach_Set(entity e, entity parent, string s) { @@ -98,6 +98,7 @@ 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_solid = e.solid; // persist solidity e.old_movetype = e.movetype; // persist physics e.movetype = MOVETYPE_FOLLOW; e.solid = SOLID_NOT; @@ -117,8 +118,8 @@ void sandbox_ObjectAttach_Remove(entity e) if(head.owner == e) { vector org; + head.solid = head.old_solid; // restore persisted solidity head.movetype = head.old_movetype; // restore persisted physics - head.solid = SOLID_BBOX; head.takedamage = DAMAGE_AIM; org = gettaginfo(head, 0); @@ -203,16 +204,18 @@ string sandbox_ObjectPort_Save(entity e, float database) 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, physics; + float slot, physics, solidity; if(head == e) // this is the main object, place it first { slot = 0; + solidity = head.solid; // applied solidity is normal solidity for children 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; + solidity = head.old_solid; // persisted solidity is normal solidity for children physics = head.old_movetype; // persisted physics are normal physics for children gettaginfo(head.owner, head.tag_index); // get the name of the tag our object is attached to, used further below } @@ -242,6 +245,7 @@ string sandbox_ObjectPort_Save(entity e, float database) 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(solidity), " "); 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 @@ -310,6 +314,7 @@ entity sandbox_ObjectPort_Load(string s, float database) 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.solid = e.old_solid = 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; @@ -440,6 +445,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) print_to(self, "^3glowmod \"value_x value_y value_z\" ^7- glow object color"); print_to(self, "^3frame value ^7- object animation frame, for self-animated models"); print_to(self, "^3scale value ^7- changes object scale. 0.5 is half size and 2 is double size"); + print_to(self, "^3solid value ^7- object collisions, 0 = non-solid, 1 = solid"); print_to(self, "^3physics value ^7- object physics, 0 = static, 1 = movable, 2 = physical"); print_to(self, "^3force value ^7- amount of force applied to objects that are shot"); print_to(self, "^3material value ^7- sets the material of the object. Default materials are: metal, stone, wood, flesh"); @@ -624,6 +630,18 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) case "scale": sandbox_ObjectEdit_Scale(e, stof(argv(3))); break; + case "solid": + switch(argv(3)) + { + case "0": // non-solid + e.movetype = SOLID_NOT; + break; + case "1": // solid + e.movetype = SOLID_BBOX; + break; + default: + break; + } case "physics": switch(argv(3)) {