]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Avoid a glitch when a dropped weapon starts bobbing and smooth passage between statio...
authorterencehill <piuntn@gmail.com>
Mon, 14 Nov 2016 01:27:12 +0000 (02:27 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 14 Nov 2016 01:27:12 +0000 (02:27 +0100)
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh

index 3a7aea729e945ae59ac1c6c6f5e5104b15c2eb47..724f3f9ddb07be217742d432f6caccb0aa46d9c7 100644 (file)
@@ -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)));
         }
     }
 
index f2308c35767756933f7c9c49be74e3668d79a2f5..418ce391767f4ff170a27f315ffbe953bab91d1a 100644 (file)
@@ -20,6 +20,7 @@ const int ISF_SIZE                            = BIT(7);
 
 .int ItemStatus;
 
+.float onground_time;
 .float fade_start;
 .float fade_end;