]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
If an item has a valid target, use it on touch (defrag support)
authorMario <mario@smbclan.net>
Mon, 12 Aug 2019 09:43:29 +0000 (19:43 +1000)
committerMario <mario@smbclan.net>
Mon, 12 Aug 2019 09:43:29 +0000 (19:43 +1000)
qcsrc/common/t_items.qc

index 466b38311214c20d0aa66baefa1a7d35fcf93c98..a6b3f45ce80632e91b33d45dde7ae924bcad11e4 100644 (file)
@@ -927,6 +927,9 @@ void Item_Touch(entity this, entity toucher)
 
 LABEL(pickup)
 
+       if(this.target && this.target != "" && this.target != "###item###") // defrag support
+               SUB_UseTargets(this, toucher, NULL);
+
        STAT(LAST_PICKUP, toucher) = time;
 
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
@@ -1314,7 +1317,11 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                        || (def.instanceOfHealth && def != ITEM_HealthSmall)
                        || (def.instanceOfArmor && def != ITEM_ArmorSmall)
                        || (itemid & (IT_KEY1 | IT_KEY2))
-               ) this.target = "###item###"; // for finding the nearest item using findnearest
+               ) 
+               {
+                       if(!this.target || this.target == "")
+                               this.target = "###item###"; // for finding the nearest item using findnearest
+               }
 
                Item_ItemsTime_SetTime(this, 0);
        }