From: terencehill Date: Mon, 14 Nov 2016 01:27:12 +0000 (+0100) Subject: Avoid a glitch when a dropped weapon starts bobbing and smooth passage between statio... X-Git-Tag: xonotic-v0.8.2~443 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f70debf2f155e50a7de2981c93bbb37ee5392d0e;p=xonotic%2Fxonotic-data.pk3dir.git Avoid a glitch when a dropped weapon starts bobbing and smooth passage between stationary and bob animation --- diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 3a7aea729..724f3f9dd 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 f2308c357..418ce3917 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;