]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use a different method of checking grab distance
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 22:51:52 +0000 (01:51 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 22:51:52 +0000 (01:51 +0300)
qcsrc/server/cheats.qc
qcsrc/server/cheats.qh
qcsrc/server/mutators/sandbox.qc

index 500a36ebe45d1fab19bfc19bd8ad925116d3fcf8..e35adab354d95b4062667fa9e1178d29444fd38f 100644 (file)
@@ -664,7 +664,7 @@ float CheatCommand(float argc)
        END_CHEAT_FUNCTION();
 }
 
-float Drag(entity e);
+float Drag(entity e, float dist);
 void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
 void Drag_Finish(entity dragger);
 float Drag_IsDraggable(entity draggee);
@@ -694,7 +694,7 @@ float CheatFrame()
                        {
                                // only use non-sandbox dragging if cheats are enabled
                                crosshair_trace_plusvisibletriggers(self);
-                               if(Drag(trace_ent) && !cvar("g_sandbox"))
+                               if(Drag(trace_ent, FALSE) && !cvar("g_sandbox"))
                                        DID_CHEAT();
                        }
                        break;
@@ -709,11 +709,15 @@ float CheatFrame()
 
 // ENTITY DRAGGING
 
-float Drag(entity e)
+float Drag(entity e, float dist)
 {
+       float inrange;
+       if(vlen(e.origin - self.origin) <= dist || !dist)
+               inrange = TRUE;
+
        if(Drag_IsDragging(self))
        {
-               if(self.BUTTON_DRAG)
+               if(self.BUTTON_DRAG && inrange)
                {
                        if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18)
                        {
@@ -745,7 +749,7 @@ float Drag(entity e)
        else
        {
                if(Drag_CanDrag(self))
-                       if(self.BUTTON_DRAG)
+                       if(self.BUTTON_DRAG && inrange)
                        {
                                crosshair_trace_plusvisibletriggers(self);
                                if(e)
index c9a449b53794a6681e2f9b5d1dd5db9be56bae3b..b563c0e13b841a539a75c46ce35c3cfe68660371 100644 (file)
@@ -12,4 +12,4 @@ float CheatFrame();
 
 void Drag_MoveDrag(entity from, entity to); // call this from CopyBody
 
-float Drag(entity e); // used by sandbox code
\ No newline at end of file
+float Drag(entity e, float dist); // used by sandbox code
\ No newline at end of file
index a97067fc7e308a3f6c24aebb562ee47fbce733b3..685425102672b1597bff062b5ccb826a6ab74a82 100644 (file)
@@ -109,10 +109,9 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerPreThink)
        if(autocvar_sv_cheats)
                return FALSE; // cheats already allow dragging all objects
 
-       makevectors(self.v_angle);
-       WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_edit, MOVE_NORMAL, self);
+       crosshair_trace_plusvisibletriggers(self);
        if(trace_ent.classname == "object")
-               if(Drag(trace_ent)) // executes the dragging
+               if(Drag(trace_ent, autocvar_g_sandbox_editor_distance_edit)) // execute the dragging
                        if(autocvar_g_sandbox_info)
                                print(strcat(self.netname, " grabbed an object at origin ", vtos(trace_ent.origin), "\n"));