From f70debf2f155e50a7de2981c93bbb37ee5392d0e Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 14 Nov 2016 02:27:12 +0100 Subject: [PATCH] Avoid a glitch when a dropped weapon starts bobbing and smooth passage between stationary and bob animation --- qcsrc/common/t_items.qc | 11 +++++++++-- qcsrc/common/t_items.qh | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 3a7aea729e..724f3f9ddb 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -82,6 +82,11 @@ void ItemDraw(entity this) if(this.ItemStatus & ITS_ANIMATE2) this.avelocity = '0 -90 0'; } + + // delay is for blocking item's position for a while; + // it's a workaround for dropped weapons that receive the position + // another time right after they spawn overriding animation position + this.onground_time = time + 0.5; } } else if (autocvar_cl_animate_items) @@ -89,13 +94,15 @@ void ItemDraw(entity this) if(this.ItemStatus & ITS_ANIMATE1) { this.angles += this.avelocity * frametime; - setorigin(this, '0 0 10' + this.oldorigin + '0 0 8' * sin(time * 2)); + float fade_in = bound(0, time - this.onground_time, 1); + setorigin(this, this.oldorigin + fade_in * ('0 0 10' + '0 0 8' * sin((time - this.onground_time) * 2))); } if(this.ItemStatus & ITS_ANIMATE2) { this.angles += this.avelocity * frametime; - setorigin(this, '0 0 8' + this.oldorigin + '0 0 4' * sin(time * 3)); + float fade_in = bound(0, time - this.onground_time, 1); + setorigin(this, this.oldorigin + fade_in * ('0 0 8' + '0 0 4' * sin((time - this.onground_time) * 3))); } } diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index f2308c3576..418ce39176 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -20,6 +20,7 @@ const int ISF_SIZE = BIT(7); .int ItemStatus; +.float onground_time; .float fade_start; .float fade_end; -- 2.39.2