First step to implementing removal of spawned objects. Currently in debugging state...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 16:54:36 +0000 (19:54 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 16:54:36 +0000 (19:54 +0300)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/sandbox.qc

index aa5030e13fe209477f81b2310aa2942e0c9f0b41..a5a035585a19cc02b5dbc4a3bd8b2b4d6040683c 100644 (file)
@@ -543,7 +543,8 @@ seta g_balance_cloaked_alpha 0.25
 
 set g_sandbox 0 "allow players to spawn and edit objects around the map"
 set g_sandbox_info 1 "print non-critical information to the server"
-set g_sandbox_editor_distance 150 "distance by which objects spawn in front of the player"
+set g_sandbox_editor_distance_spawn 150 "distance at which objects spawn in front of the player"
+set g_sandbox_editor_distance_edit 250 "distance at which players can edit or remove objects they are looking at"
 
 set g_playerclip_collisions 1 "0 = disable collision testing against playerclips, might be useful on some defrag maps"
 set g_botclip_collisions 1 "0 = disable collision testing against botclips, might be useful on some defrag maps"
index be32c8ab860d7a6aee410a7a89cbdbd19e6401fb..18f3b6ba0b9889b1fc506cdd75f10b8c2d043603 100644 (file)
@@ -1200,4 +1200,5 @@ float autocvar_g_trueaim_minrange;
 float autocvar_g_debug_defaultsounds;
 float autocvar_g_loituma;
 float autocvar_g_sandbox_info;
-float autocvar_g_sandbox_editor_distance;
+float autocvar_g_sandbox_editor_distance_spawn;
+float autocvar_g_sandbox_editor_distance_edit;
index 48b7da9489c01d9991f2911fe30f4d79c4310844..a39223654a89c341f710ce41a731af00d3d1a640 100644 (file)
@@ -31,7 +31,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                return TRUE;
                        }
 
-                       // spawn a new object with the default settings
+                       // spawn a new object
                        entity e;
                        e = spawn();
                        e.owner = self;
@@ -40,10 +40,10 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 
                        // those properties are defaults that can be edited later
                        e.movetype = MOVETYPE_TOSS;
-                       e.solid = SOLID_TRIGGER;
+                       e.solid = SOLID_BBOX;
 
                        makevectors(self.v_angle);
-                       traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance, MOVE_NOMONSTERS, self);
+                       traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_spawn, MOVE_NOMONSTERS, self);
                        setorigin(e, trace_endpos);
                        setmodel(e, argv(2));
                        e.angles_y = self.v_angle_y; // apply the player's direction to the object, as he spawns it from behind
@@ -51,11 +51,12 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                        if(autocvar_g_sandbox_info)
                                print(strcat(self.netname, " spawned an object at origin ", vtos(e.origin), "\n"));
 
+dprint(strcat(vtos(e.absmin), " - ", vtos(e.absmax), "\n"));
+
                        return TRUE;
                }
                else if(argv(1) == "spawn_item")
                {
-                       // spawn a new item
                        // weapons are the only items currently supported
 
                        if(cmd_argc < 3)
@@ -64,10 +65,11 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                return TRUE;
                        }
 
+                       // spawn a new item
                        entity e;
                        float i;
                        makevectors(self.v_angle);
-                       traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance, MOVE_NOMONSTERS, self);
+                       traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_spawn, MOVE_NOMONSTERS, self);
 
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
@@ -84,6 +86,25 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                        print_to(self, "WARNING: Attempted to spawn an invalid or unsupported item. See 'g_sandbox help' for supported items");
                        return TRUE;
                }
+               else if(argv(1) == "remove_object")
+               {
+                       makevectors(self.v_angle);
+                       traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_edit, MOVE_NORMAL, self);
+                       if(trace_ent.classname == "object")
+                       {
+                               if(autocvar_g_sandbox_info)
+                                       print(strcat(self.netname, " removed an object at origin ", vtos(trace_ent.origin), "\n"));
+                               remove(trace_ent);
+                               trace_ent = world;
+                               return TRUE;
+                       }
+
+dprint(strcat(trace_ent.classname, "\n"));
+te_lightning2(world, self.origin + self.view_ofs + v_forward * 5 - v_up * 5, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_edit);
+
+                       print_to(self, "WARNING: Object could not be removed. Make sure you are facing an object that you have spawned");
+                       return TRUE;
+               }
        }
        return FALSE;
 }