From: Mario Date: Mon, 24 Sep 2018 07:13:26 +0000 (+1000) Subject: Add a way for entities to tell whether they're draggable (currently unused) X-Git-Tag: xonotic-v0.8.5~1834 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4fa5f7c3784ebaa8d112e55271ed55046b1a4370;p=xonotic%2Fxonotic-data.pk3dir.git Add a way for entities to tell whether they're draggable (currently unused) --- diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index e894e85b4..5bf11df86 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -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; diff --git a/qcsrc/server/cheats.qh b/qcsrc/server/cheats.qh index 0dc6a92d9..22cded8cb 100644 --- a/qcsrc/server/cheats.qh +++ b/qcsrc/server/cheats.qh @@ -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);