Allow grabbing to be used for sandbox objects, even when sv_cheats is disabled. The...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 22:04:06 +0000 (01:04 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 22:04:06 +0000 (01:04 +0300)
qcsrc/server/mutators/sandbox.qc

index 73701a9225d83565563b98ffa3d26b50cb007151..91fd4dd79d42b54537bd645a614664e77cf27e76 100644 (file)
@@ -102,9 +102,26 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
        return FALSE;
 }
 
+MUTATOR_HOOKFUNCTION(sandbox_PlayerPreThink)
+{
+       // if the player is close enough to their own object and facing it, they can grab it
+
+       if(autocvar_sv_cheats)
+               return FALSE; // cheats already allow dragging all objects
+
+       WarpZone_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(Drag(trace_ent)) // executes the dragging
+                       if(autocvar_g_sandbox_info)
+                               print(strcat(self.netname, " grabbed an object at origin ", vtos(trace_ent.origin), "\n"));
+
+       return FALSE;
+}
+
 MUTATOR_DEFINITION(sandbox)
 {
        MUTATOR_HOOK(SV_ParseClientCommand, sandbox_PlayerCommand, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerPreThink, sandbox_PlayerPreThink, CBC_ORDER_ANY);
 
        return 0;
 }