]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a way for entities to tell whether they're draggable (currently unused)
authorMario <mario@smbclan.net>
Mon, 24 Sep 2018 07:13:26 +0000 (17:13 +1000)
committerMario <mario@smbclan.net>
Mon, 24 Sep 2018 07:13:26 +0000 (17:13 +1000)
qcsrc/server/cheats.qc
qcsrc/server/cheats.qh

index e894e85b4fa045026bd09683b8a5dd57f0e02327..5bf11df86ef5a732d3f59401423ab8ed0705a554 100644 (file)
@@ -839,7 +839,7 @@ float Drag(entity this, float force_allow_pick, float ischeat)
                                                }
                                                // Find e and pick
                                                if(e && pick)
-                                                       if(Drag_IsDraggable(e))
+                                                       if(Drag_IsDraggable(e, this))
                                                        {
                                                                if(ischeat)
                                                                        IS_CHEAT(this, 0, 0, CHRAME_DRAG);
@@ -915,7 +915,7 @@ void Drag_Finish(entity dragger)
        }
 }
 
-float Drag_IsDraggable(entity draggee)
+float Drag_IsDraggable(entity draggee, entity dragger)
 {
        // TODO add more checks for bad stuff here
        if(draggee == NULL)
@@ -939,7 +939,7 @@ float Drag_IsDraggable(entity draggee)
        if(draggee.classname == "weaponentity")
                return false;
 
-       return true;
+       return ((draggee.draggable) ? draggee.draggable(draggee, dragger) : true);
 }
 
 float Drag_MayChangeAngles(entity draggee)
@@ -1017,7 +1017,7 @@ float Drag_IsDragging(entity dragger)
                dragger.dragentity = NULL;
                return false;
        }
-       if(!Drag_CanDrag(dragger) || !Drag_IsDraggable(dragger.dragentity))
+       if(!Drag_CanDrag(dragger) || !Drag_IsDraggable(dragger.dragentity, dragger))
        {
                Drag_Finish(dragger);
                return false;
index 0dc6a92d9c45b5f103e432fabaa59f8c3db45bb1..22cded8cb986682a23a0a0d8307adf9452e62b3f 100644 (file)
@@ -14,12 +14,13 @@ float CheatFrame(entity this);
 
 const float CHRAME_DRAG = 8;
 
+.bool(entity this, entity dragger) draggable;
 void Drag_MoveDrag(entity from, entity to); // call this from CopyBody
 void DragBox_Think(entity this);
 float Drag(entity this, float force_allow_pick, float ischeat);
 void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
 void Drag_Finish(entity dragger);
-float Drag_IsDraggable(entity draggee);
+bool Drag_IsDraggable(entity draggee, entity dragger);
 float Drag_MayChangeAngles(entity draggee);
 void Drag_MoveForward(entity dragger);
 void Drag_SetSpeed(entity dragger, float s);