]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/items/items.qc
Merge branch 'master' into z411/annce_queue
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / items / items.qc
index ea325eeebb12cd4a735ff3f9375e73b0ebe90952..6a19a435f2a502c05d0e6c8ed39ca7565c3a3601 100644 (file)
@@ -199,7 +199,6 @@ void Item_Respawn(entity this)
 {
        Item_Show(this, 1);
        sound(this, CH_TRIGGER, this.itemdef.m_respawnsound, VOL_BASE, ATTEN_NORM);     // play respawn sound
-       setorigin(this, this.origin);
 
        if (Item_ItemsTime_Allow(this.itemdef) || (STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS))
        {
@@ -635,7 +634,7 @@ void Item_Touch(entity this, entity toucher)
        {
                if (ITEM_TOUCH_NEEDKILL())
                {
-                       delete(this);
+                       RemoveItem(this);
                        return;
                }
        }
@@ -728,7 +727,6 @@ LABEL(pickup)
 void Item_Reset(entity this)
 {
        Item_Show(this, !this.state);
-       setorigin(this, this.origin);
 
        if (Item_IsLoot(this))
        {
@@ -748,12 +746,9 @@ void Item_Reset(entity this)
 
 void Item_FindTeam(entity this)
 {
-       entity e;
-
-       if(!(this.effects & EF_NODRAW))
+       if(!(this.effects & EF_NOGUNBOB)) // marker for item team search
                return;
 
-       // marker for item team search
        LOG_TRACE("Initializing item team ", ftos(this.team));
        RandomSelection_Init();
        IL_EACH(g_items, it.team == this.team,
@@ -762,7 +757,7 @@ void Item_FindTeam(entity this)
                        RandomSelection_AddEnt(it, it.cnt, 0);
        });
 
-       e = RandomSelection_chosen_ent;
+       entity e = RandomSelection_chosen_ent;
        if (!e)
                return;
 
@@ -772,13 +767,17 @@ void Item_FindTeam(entity this)
                {
                        if(it != e)
                        {
-                               // make it non-spawned
-                               Item_Show(it, -1);
-                               it.state = 1; // state 1 = initially hidden item, apparently
+                               Item_Show(it, -1); // make it non-spawned
+                               if (it.waypointsprite_attached)
+                                       WaypointSprite_Kill(it.waypointsprite_attached);
+                               it.nextthink = 0; // disable any scheduled powerup spawn
                        }
                        else
                                Item_Reset(it);
-                       it.effects &= ~EF_NODRAW;
+
+                       // leave 'this' marked so Item_FindTeam() works when called again via this.reset
+                       if(it != this)
+                               it.effects &= ~EF_NOGUNBOB;
                }
        });
 }
@@ -787,6 +786,8 @@ void Item_FindTeam(entity this)
 void RemoveItem(entity this)
 {
        if(wasfreed(this) || !this) { return; }
+       if(this.waypointsprite_attached)
+               WaypointSprite_Kill(this.waypointsprite_attached);
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
        delete(this);
 }
@@ -975,9 +976,16 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
        precache_model(this.model);
        precache_sound(this.item_pickupsound);
 
+       if(q3compat && !this.team)
+       {
+               string t = GetField_fullspawndata(this, "team", false);
+               // bones_was_here: this hack is cheaper than changing to a .string strcmp()
+               if(t) this.team = crc16(false, t);
+       }
+
        if (Item_IsLoot(this))
        {
-               this.reset = SUB_Remove;
+               this.reset = RemoveItem;
                set_movetype(this, MOVETYPE_TOSS);
 
                // Savage: remove thrown items after a certain period of time ("garbage collection")
@@ -1017,7 +1025,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                if(this.angles != '0 0 0')
                        this.SendFlags |= ISF_ANGLES;
 
-               this.reset = Item_Reset;
+               this.reset = this.team ? Item_FindTeam : Item_Reset;
                // it's a level item
                if(this.spawnflags & 1)
                        this.noalign = 1;
@@ -1127,7 +1135,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                if(!this.cnt)
                        this.cnt = 1; // item probability weight
 
-               this.effects |= EF_NODRAW; // marker for item team search
+               this.effects |= EF_NOGUNBOB; // marker for item team search
                InitializeEntity(this, Item_FindTeam, INITPRIO_FINDTARGET);
        }
        else