From d6e1e75b581a4d29e6c1bb69de24845e3994c795 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 24 Sep 2018 18:07:29 +1000 Subject: [PATCH] Add an undraggable function and make use of it in the exclusions --- qcsrc/common/mapobjects/func/bobbing.qc | 2 ++ qcsrc/common/mapobjects/func/button.qc | 1 + qcsrc/common/mapobjects/func/plat.qc | 1 + qcsrc/server/cheats.qc | 23 ++++++++--------------- qcsrc/server/cheats.qh | 2 ++ qcsrc/server/client.qc | 3 +++ qcsrc/server/weapons/weaponsystem.qc | 2 ++ 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/qcsrc/common/mapobjects/func/bobbing.qc b/qcsrc/common/mapobjects/func/bobbing.qc index b647e15a8..60920fafb 100644 --- a/qcsrc/common/mapobjects/func/bobbing.qc +++ b/qcsrc/common/mapobjects/func/bobbing.qc @@ -48,6 +48,8 @@ spawnfunc(func_bobbing) this.active = ACTIVE_ACTIVE; + this.draggable = drag_undraggable; + // damage when blocked setblocked(this, generic_plat_blocked); if(this.dmg && (this.message == "")) diff --git a/qcsrc/common/mapobjects/func/button.qc b/qcsrc/common/mapobjects/func/button.qc index 44e312843..a8537f172 100644 --- a/qcsrc/common/mapobjects/func/button.qc +++ b/qcsrc/common/mapobjects/func/button.qc @@ -158,6 +158,7 @@ spawnfunc(func_button) precache_sound(this.noise); this.active = ACTIVE_ACTIVE; + this.draggable = drag_undraggable; this.pos1 = this.origin; this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip); diff --git a/qcsrc/common/mapobjects/func/plat.qc b/qcsrc/common/mapobjects/func/plat.qc index b05233621..53dbed02f 100644 --- a/qcsrc/common/mapobjects/func/plat.qc +++ b/qcsrc/common/mapobjects/func/plat.qc @@ -103,6 +103,7 @@ spawnfunc(func_plat) this.angles = '0 0 0'; this.classname = "plat"; + this.draggable = drag_undraggable; if (!InitMovingBrushTrigger(this)) return; this.effects |= EF_LOWPRECISION; diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 5bf11df86..5ca5270d6 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -915,29 +915,22 @@ void Drag_Finish(entity dragger) } } +bool drag_undraggable(entity draggee, entity dragger) +{ + // stuff probably shouldn't need this, we should figure out why they do! + // exceptions of course are observers and weapon entities, where things mess up + return false; +} + float Drag_IsDraggable(entity draggee, entity dragger) { // TODO add more checks for bad stuff here if(draggee == NULL) return false; - if(draggee.classname == "func_bobbing") - return false; if(draggee.classname == "door") // FIXME find out why these must be excluded, or work around the problem (trying to drag these causes like 4 fps) - return false; - if(draggee.classname == "plat") - return false; - if(draggee.classname == "func_button") - return false; + return false; // probably due to BSP collision // if(draggee.model == "") // return false; - if(IS_SPEC(draggee)) - return false; - if(IS_OBSERVER(draggee)) - return false; - if(draggee.classname == "exteriorweaponentity") - return false; - if(draggee.classname == "weaponentity") - return false; return ((draggee.draggable) ? draggee.draggable(draggee, dragger) : true); } diff --git a/qcsrc/server/cheats.qh b/qcsrc/server/cheats.qh index 22cded8cb..962e017a1 100644 --- a/qcsrc/server/cheats.qh +++ b/qcsrc/server/cheats.qh @@ -14,6 +14,8 @@ float CheatFrame(entity this); const float CHRAME_DRAG = 8; +bool drag_undraggable(entity draggee, entity dragger); + .bool(entity this, entity dragger) draggable; void Drag_MoveDrag(entity from, entity to); // call this from CopyBody void DragBox_Think(entity this); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 8f7c52f32..18d3d4ea3 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -347,6 +347,7 @@ void PutObserverInServer(entity this) this.crouch = false; STAT(REVIVE_PROGRESS, this) = 0; this.revival_time = 0; + this.draggable = drag_undraggable; this.items = 0; STAT(WEAPONS, this) = '0 0 0'; @@ -677,6 +678,8 @@ void PutPlayerInServer(entity this) this.event_damage = PlayerDamage; this.event_heal = PlayerHeal; + this.draggable = func_null; + if(!this.bot_attack) IL_PUSH(g_bot_targets, this); this.bot_attack = true; diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 2017e65a7..d9155c223 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -178,6 +178,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity) setthink(view, CL_Weaponentity_Think); view.nextthink = time; view.viewmodelforclient = actor; + view.draggable = drag_undraggable; setcefc(view, CL_Weaponentity_CustomizeEntityForClient); wepent_link(view); @@ -187,6 +188,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity) entity exterior = actor.exteriorweaponentity = new(exteriorweaponentity); exterior.solid = SOLID_NOT; exterior.owner = actor; + exterior.draggable = drag_undraggable; exterior.weaponentity_fld = weaponentity; setorigin(exterior, '0 0 0'); setthink(exterior, CL_ExteriorWeaponentity_Think); -- 2.39.2